This is a stupid question, but I just don't know why it isn't working.
I am trying to copy the files from FolderA to FolderB recursively. I am doing this:
Copy-Item -Path "C:\FolderA\" -Destination "C:\FolderB\" -recurse -Force -Verbose
It works great, no problem.
Except the result in FolderB is this:
C:\FolderB\FolderA\file.txt
Whereas I want it to be:
C:\FolderB\file.txt
What stupid obvious thing am I missing?
Best Answer
Your command is telling PowerShell to copy the folder itself, with all its contents, to the destination folder. To copy only the contents of the original folder, change your path as follows:
Notice the asterisk (*) after the folder name. This will copy the content (including subfolders) of the folder, but not the folder itself to the destination folder.
Using the Copy-Item Cmdlet