简体   繁体   English

Powershell:将父文件夹中的所有子目录和内容复制到另一个文件夹目标

[英]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 我想将所有子目录复制到C:\\ Destination

How would I write Powershell program which takes all multiple variable subfolders and copies into Directory? 我如何编写Powershell程序,它将所有多个变量子文件夹和副本带入目录?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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