Bulk Renaming Files

by Sep 8, 2011

Rename-Item can rename hundreds of files in one step. Have a look:

$global:i = 1 dir c:\test1\ -Filter cover*.jpg | Rename-Item -NewName { "picture_$i.jpg" $global:i++}

This line will take all *.jpg files in c:\test1 and rename them to “picture_x.jpg” where “x” is an incrementing number. The secret is to submit a script block to Rename-Item, which will then dynamically calculate the name that will need to be assigned to a particular file.

Twitter This Tip!
ReTweet this Tip!