Bulk Renaming Files

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!


Posted Sep 08 2011, 06:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.