Windows Powershell - Rename a list of files using a list from a text document

点点圈 提交于 2020-01-05 01:09:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!