简体   繁体   中英

Powershell: Copy all Subdirectory and Contents in Parent Folder to Another Folder Destination

I have some folders called

C:\Source
C:\Destination

C:\Source contains 
  ---> FolderA (having few files)
  ---> FolderB (having few files)
  ... etc

I want to copy all subdirectories into C:\\Destination

How would I write Powershell program which takes all multiple variable subfolders and copies into Directory?

This does not work, as it is results in copying all of Source Folder into Destination resulting in

How to copy folder with subfolders?

C:\Destination\Source

Would like to keep same subdirectory folder structure

This seems to work

Get-ChildItem -Path "C:\Source" |
Copy-Item -Force -Destination "C:\Destination" -Recurse -Container

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM