Bulk Rename Files & Folders

I recently found myself having to update several document categories to new values. From the NetTrax.NET database side this was a breeze, a few simple SQL update statements and I was done. The problem was, the document categories are used to name file folders out on a Windows® file share. Going through and manually renaming 20,000+ folders was out of the question for obvious reasons.

Enter the amazing (and free!) Bulk Rename Utility.

Here is a look at the Bulk Rename Utility main operation screen:

This probably looks a little, ok a lot, overwhelming. That’s because from this UI you can perform just about all the updates you might ever need on files/folders. The options are very well documented in the included help file so I’m not going to go in to it here.

There is a drawback to using the UI. When you select your folder from the tree on the left it has to load in all the folders, sub-folders and files (depending on what options you have selected). When you have 20,000+ folders this refresh takes a substantial amount of time.

Thankfully, Bulk Rename Utility has a cousin called Bulk Rename Command (BRC). Bulk Rename Command allows you to perform most of, if not all, the functions in the Bulk Rename Utility UI via the Windows® Command Prompt.

So, I started out with an Excel Spreadsheet to build my command with the parameters I needed.

 

Using Excel I break down the whole command into chunks then put it back together using the CONCATENATE function.

  1. This column includes the command line application, some switches and the directory to start in.
  2. The folder names to find.
  3. The folder names to replace with.
  4. Some more switches and syntax to output to a log txt file rather than showing the information on the screen.
  5. The first four columns CONCATENATED into one long command.

The switches are detailed very well in the included help file but I’ll go over the ones I used here.

/NOFILES – This means evaluate (and rename) folders only.

/RECURSIVE – This tells BRC to go through any and all sub-folders

/DIR:”DirectoryName” – Tells BRC what directory to start from.

/REPLACE:”FindText”:”ReplaceText” – Tells BRC what text to look for and what text to replace it with.

/EXECUTE – This is a cool switch. Basically BRC will let you enter all your switches and then run. It will ‘look’ just like it is running, however, it doesn’t actually modify anything. Think of this as a ‘preview’ before you unleash BRC on your files/folders. By adding the /EXECUTE switch that tells BRC to go ahead and actually perform the update(s). So, be careful with this switch!

>> “FilePath\Name.txt” – Since the Command Line screen is somewhat limited and I was working with 20,000+ folders I didn’t want the output to just go scrolling along on the screen. I wanted to be able to go back and look at everything BRC did and review it, especially useful if something goes horribly wrong. The > symbol followed by a filename.txt will output the data on the screen to a text file. By using two >> characters you are telling the Command Line application to append the data to the file not overwrite it.

Here is a sample from the log text file:

You can see where it passed over the BENEFITS (US) folder as it required no change, however, once it got to Compensation (Green) it was renamed to COMPENSATION (US).

By using a .BAT file and running this as a command the entire thing processed in under five minutes. Try renaming even a hundred folders in that time, BRC did 20,000+!