有一个powershell问题。我将其分解为项目符号;
任何帮助将不胜感激。
答案 0 :(得分:0)
这不是我编写的最精美的代码,但是可以完成工作:
$destination = "x:\files\"
Get-Content "paths.txt" | foreach {
Get-ChildItem $_\* | foreach {
$suffix = 0
do {
if ($suffix -eq 0) {$name = $_.Name}
else {$name = $_.BaseName + "_" + $suffix + $_.Extension}
$suffix++
}
until(-not(Test-Path (Join-Path $destination $name)))
Copy-Item $_.FullName (Join-Path $destination $name)
}
}