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.'}
精彩评论