我可以帮助您翻译以下内容:
希望的结果是:
到目前为止,我想到了以下内容:
然而,PowerShell中“一切皆为对象”的理念让我感到困惑(至少我认为是这样)。也就是说,文件被复制了,但是没有它们的相对路径。
有人能否给我一点启示?
我想从特定子目录中复制某种类型的所有文件,并保留它们相对于该子目录的路径,将其移至另一个目录并保留相对路径。例如:
源子目录:
c:\temp\sourcedirectory
源文件:
c:\temp\sourcedirectory\tonymontana\fileOne.txt
c:\temp\sourcedirectory\poker\fileTwo.txt
目标目录:
c:\temp\targetdirectory
希望的结果是:
c:\temp\targetdirectory\tonymontana\fileOne.txt
c:\temp\targetdirectory\poker\fileTwo.txt
到目前为止,我想到了以下内容:
Set-Location $srcRoot
Get-ChildItem -Path $srcRoot -Filter $filePattern -Recurse |
Resolve-Path -Relative |
Copy-Item -Destination {Join-Path $buildroot $_.FullName}
然而,PowerShell中“一切皆为对象”的理念让我感到困惑(至少我认为是这样)。也就是说,文件被复制了,但是没有它们的相对路径。
有人能否给我一点启示?
xcopy
、robocopy
、rsync
等。 - Ansgar Wiechers