27.5.06

[PowerShell] Bulk file rename

Among many cool things you could do with PowerShell, the one I started using first, and use the most is bulk file renaming.

Digital cameras save pictures with most undescriptive names possible like ABC#####.jpg or HPIMG###.jpg. I like to store pictures properly named so I wouldn’t have to open photos in every folder just to locate one specific.


This PowerShell script does exactly that: locates every JPG file in current folder and renames it into “Picture###.jpg”.

 Enjoy!



$i = 0;
dir | where { $_.Name.ToLower().EndsWith("jpg") } | foreach { rename-item $_ Picture_$i.jpg; $i = $i + 1; }

No comments: