4

i have two folders "C:\Source1" and "C:\Source2". Im using powershell to copy items from these two folders to single destination folder

Copy-Item "C:\Source1" "C:\Destination" -recurse -force

this creates a "C:\Destination" folder and copies all files & directories from "Source1" as expected. Note it does not create "Source1" folder under "C:\Destination"

Now i run the following command

 Copy-Item "C:\Source2" "C:\Destination" -recurse -force

This time instead of coping all the child items under "Source2" it creates a new folder "Source2" under "C:\Destination" and copies all child files & directories under "C:\Destination\Source2"

LP13
  • 30,567
  • 53
  • 217
  • 400

1 Answers1

6

Tell the cmdlet that you want to copy the folder's content instead of the folder itself:

Copy-Item 'C:\Source2\*' 'C:\Destination' -Recurse -Force
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328