开发者

rename files in powershell

I would like to 开发者_高级运维ask for help in renaming files in given folder.

I would like to change characters "vol._" to "vol."

thanks for help


 gci c:\folder_path | ? {$_.name -match 'vol._'} | 
     rename-item -newname {$_.name  -replace 'vol._','vol.'} -whatif

Take a look at the output and if everything works fine remove whatif switch

edit. If you need to rename files even in subfolders you have to apply a little change

 gci c:\folder_path -rec | ? {!$_.psiscontainer -and $_.name -match 'vol._'} |
     rename-item -newname {$_.name  -replace 'vol._','vol.'} -whatif


What about:

gci c:\folderpath -include vol._* | rename-item -newname {$_.name -replace 'vol._', 'vol.'}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜