问题
I tried using the following code to rename a folder of files "C:\www\folderx"
using a text list "..\list.txt"
, but I can't figure out how to get the current file index:
Get-Childitem C:\www\folderx | % {
$OldName = $_.name;
$NewName = (GC ..\list.txt)[<CURRENT INDEX SHOULD GO HERE>];
# Rename-Item -Newname $NewName;
Write-Output $("Renamed {0} to {1}" -f $OldName,$NewName);
}
来源:https://stackoverflow.com/questions/17256501/windows-powershell-rename-a-list-of-files-using-a-list-from-a-text-document