如何使用 PowerShell copy-item 并保持结构 [英] How to use PowerShell copy-item and keep structure
本文介绍了如何使用 PowerShell copy-item 并保持结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目录结构如下所示:
I have a directory structure that looks like this:
C:\folderA\folderB\folderC\client1\f1\files
C:\folderA\folderB\folderC\client1\f2\files
C:\folderA\folderB\folderC\client2\f1\files
C:\folderA\folderB\folderC\client2\f2\files
C:\folderA\folderB\folderC\client3\f1\files
C:\folderA\folderB\folderC\client4\f2\files
我想复制 C:\tmp\ 中 f1
文件夹的内容来得到这个
I want to copy the content of the f1
folders in C:\tmp\ to get this
C:\tmp\client1\f1\files
C:\tmp\client2\f1\files
C:\tmp\client3\f1\files
我试过了:
Copy-Item -recur -path: "*/f1/" -destination: C:\tmp\
但是它复制了内容而没有正确复制结构.
But it copies the contents without copying the structure correctly.
推荐答案
在 PowerShell 3.0 及更高版本中,这只是通过这种方式完成的:
In PowerShell version 3.0 and newer this is simply done this way:
Get-ChildItem -Path $sourceDir | Copy-Item -Destination $targetDir -Recurse -Container
这篇关于如何使用 PowerShell copy-item 并保持结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文