Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to alter the built in mechanism for mass renaming in Win7?

enter image description here

Lets say, is it possible to make it use a pattern like this?

share|improve this question

I've never been able to find a way to alter the format the Windows uses for batch renaming. There are however third-party utilities that handle it without issue. I personally use but there are others as well.

share|improve this answer
Thanks. I am aware of renaming tools but I'm just to lazy to open a whole application, browse to a folder, mark files, set rename pattern (or default it), do the rename and close the application!... – Odys May 1 '12 at 19:22
I love how you know this will do what you want because there was no design team behind it at all. Look at how cluttered and awful the UI is, that's how you know software engineers put this together! – Rob May 1 '12 at 19:23

You could use a scripting language. PowerShell should be on your Win7 box. Here's a one-liner:

PS> get-childitem | foreach { $i++; $new = "name-{0:D3}" -f $i + $_.Extension; rename-item $_ $new } ; $i=0

Here, we use Get-ChildItem to enumerate the contents of the current directory. Then, we pipe the resulting FileInfo objects to a short ScriptBlock, that does the following:

  • Increment a counter variable
  • Create a new name by combining
    • a formatted string, with three significant digits for the counter
    • the file extension from the original FileInfo object
  • Use Rename-Item with the original FileInfo object and the new name

That last item resets the $i counter; useful as you experiment so that the first filename starts with 1, rather than one more than the final value it had last time you rant he script. (Ask me how I know).

Put that together, and here's what you get:

Executed in a directory with the following contents:

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         10/3/2011  11:45 AM        455 save-times.csv
-a---         2/23/2012   4:03 PM     553376
-a---          2/1/2012  10:55 AM     131280 user-gp.html
-a---          6/7/2011  11:58 AM      38557 wks.xml
-a---         5/23/2011   3:28 PM      16384 xmllint.exe

I get the following result:

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         10/3/2011  11:45 AM        455 name-001.csv
-a---         2/23/2012   4:03 PM     553376
-a---          2/1/2012  10:55 AM     131280 name-003.html
-a---          6/7/2011  11:58 AM      38557 name-004.xml
-a---         5/23/2011   3:28 PM      16384 name-005.exe

For more information, see TechNet docs on Using the Get-ChildItem Commandlet and Using the Foreach-Object Commandlet. Go ahead; try it!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .