Xcopy命令:如何仅显示复制的文件的目标路径

时间:2013-11-21 13:06:06

标签: regex xcopy

我正在使用像这样的xcopy命令 -

xcopy  /y/i/e/f \oldLocation \newLocation

我得到这样的输出:

D:\temp\src\a.txt-> C:\Temp\a.txt

复制成功后,我需要xcopy为目标文件(仅C:\Temp\a.txt)提供完整路径。我已经尝试了/ l标志,它给出了输出 -

D:a.txt

有办法做到这一点吗?或者我是否必须手动提取目标路径。

1 个答案:

答案 0 :(得分:0)

为什么不使用Powershell?

$oldLocation = "C:\OldFolder\" 
$newLocation = "D:\NewFolder\"

ForEach ($item in (gci $oldLocation)) {
    Write-Host $newLocation$item # Tells you what is being copied
    Copy-Item $item.fullname $newLocation$item
}