Reputation: 20356
I have subfolders which have names:
I would like to rename all of these to:
Is there an easy way of doing this in windows (perhaps using powershell or something in command prompt ) ?
Upvotes: 1
Views: 1971
Reputation: 2184
Try this.
Get-ChildItem C:\path-to-directory -Recurse -Filter *foo* | Rename-Item -NewName { $_.name -replace 'foo', 'bar'} -verbose
Upvotes: 0
Reputation: 126732
You can do that in two Rename-Item calls. The first would add a prefix to each name to avoid the 'Source and destination path must be different.' error. The second run will remove the prefix.
Get-ChildItem -Filter original_optimize -Recurse |
Rename-Item -NewName __foo__Original_Optimize -PassThru |
Rename-Item -NewName {$_.Name -replace '^__foo__'} -PassThru
Upvotes: 2