Search This Blog

Tuesday, July 23, 2013

PowerShell–batch search/replace in filenames

I needed to rename a set of files , keeping the original name but adding a suffix. Powershell can do this quite easily using the following:

 

PS C:\data\photos> Dir | Rename-Item -NewName { $_.name -replace ".jpg","_840.jpg" }

 

this will take all .jpg files in the folder and change the name to include an _840.jpg… which in my case was the vertical dimensions of the image set.

No comments: