Mark Gilbert's Blog

Science and technology, served light and fluffy.

Windows Explorer Tricks

A couple of weeks ago I was reorganizing some files, and accidently left a group of them selected when I hit F2.  I had intended to only rename one of them, but leaving them all selected resulted in ALL of them being renamed to something else.  I had not come across the bulk renaming feature of Windows Explorer, but after some exploration through Google result sets I found that I wasn’t the first to find this.  I decided to put it through its paces to see how far I could extend it.

Let’s say I start with the following files in some directory (this will be our “original” file set):


I select all of them, right click on First.txt, and select “Rename” (or simply hit F2).  Rename it to “1 First.txt” and press Enter.  What happens?  All selected files have now been changed:

1 First.txt
1 First (1).txt
1 First (2).txt
1 First (3).txt
1 First (4).pdf
1 First (5).doc

Explorer tries to rename all of them as “1 First”, but it also needs to preserve the uniqueness of each of the file names, so it uses the same format when copying a file from one folder into the same folder.  What is interesting here is that the original file extensions are preserved.  Let’s call this “Rename Pattern A”.

Now, if you were to wrap the number in parentheses, and rename “First.txt” to “(1) First.txt”,  here’s what the original file set becomes:

(1) First.txt

The second and subsequent files are renamed according to a pattern, and again, the original file extensions are preserved.  Let’s call this “Rename Pattern B”.

If you were to try to rename the file as “-1- First.txt” (minus signs instead of parentheses), it would follow Rename Pattern A where everything had “-1-” prefacing it (the numbers would NOT increment themselves).  If you tried “a First.txt”, it would also follow Rename Pattern A.

If you tried “(a) First.txt”, however, you would get a slightly modified Rename Pattern B.  Instead of the numbers going from “(2)” to “(6)”, they would go from “(1)” to “(5)” because the first file in the list would have “(a)” as its prefix.

A little more experimentation shows that the left parenthesis seems to be the sole trigger for Rename Pattern B.  If you follow the left parentheses with a number (with or without the closing parenthesis), the pattern will start with that number.  For example, renaming “First.txt” to “(9) First.txt” forces the other files to be renamed as “(10)” through “(14)”.  The catch with the number is that it only looks at the first whole number.  Trying to use “(1.1)” will result in numbers “(2)” through “(6)” being used for the other files – it ignores the “.1”.

Interestingly enough, you can even start with a negative number, and have it count up from there.  Starting with -1 will result in the other files being named with 0 through 4.  Starting with -11 results in -10 through -6 for the other five files.

The number that you start with has its limits, though.  If you use 123456789, you will get numbers 123456790 through 123456794 for the other files.  If you try to use 12345678901 you will get -539222982 through -539222986.  This look suspiciously like a 32-bit limit, so I tried 2,147,483,647 (231 – 1), and sure enough the other numbers were -2,147,483,647 through -2,147,483,644.  If I backed down my initial number a bit, such as use 2,147,483,640, the other numbers would march right up to 2,147,483,647, and then head into the negative values.

In all of the above experiments, the parentheses and number were at the very beginning of the file.  What happens if you place it at the end of the main file name, but before the period?

First (1.txt
First (2).txt
First (3).txt
First (4).txt
First (5).pdf
First (6).doc

Notice that I didn’t start with the closing parenthesis, but it adds it to all of the others.

For all of these patterns and subpatterns, however, if you hit CTRL-Z (or Edit/Undo Rename) repeatedly, you’ll see that the files were renamed individually, and you can undo them one at a time.

When I first stumbled onto this a couple of weeks ago, it certainly raised an eyebrow, and caused me to ask “what the heck key combination did I hit for THAT?!?”  But in the end, it turned out to be merely a built-in feature of Windows Explorer.  I found a few posts on various newsgroups saying that this trick was limited to Windows XP’s version of Windows Explorer, but I would be willing to suspect it has made its way into Vista, and perhaps has even gotten a little more sophisticated.

February 13, 2007 - Posted by | General

1 Comment

  1. useful thanks

    Comment by Anonymous | March 8, 2009

Sorry, the comment form is closed at this time.

%d bloggers like this: