Regular Expression File Renaming Utility

Updated: June 12, 2006 - I had some debug code in there, basically a sleep for a second statement - doh! - I've removed it and Zip file updated

There have been numerous times that I’ve needed the ability to rename a set of files based upon a pattern, something regular expressions could easily take care of if the old DOS rename command, or something built into the Windows OS could do.  However, there’s nothing in Windows base set of command utilities that can provide this.  I haven’t delved into Windows PowerShell (fka Monad) enough to see if this capability exists already.  But, I had a bunch of pictures that I wanted renamed in my library and just needed a utility to do it.

So, I built this utility to help me rename files, by directory, based upon Regular Expression patterns.

A Zip archive of the Solution files are File Rename Utility Zip File solution that contains the following:

  • Visual Studio Solution
  • Windows Installer
  • Program Executable

 The following is a screen shot of the tool after reading a directory and running a trial.

View of Utility

This version doesn’t have batch capabilities.  It does leverage the BackgroundWorker class for handling both the trial and actual renaming of the files so the UI doesn’t block during long processing.  So, that means it can be used on a network directory.  Below is a screen shot of it running against a UNC name.

FileName utility running against UNC name

About

Shawn Cicoria is a Consultant with Avanade (www.Avanade.com) the leading Systems Integration Consultancy focused on the Microsoft Platform. Shawn is also a MCT training instructor with SetFocus (www.Setfocus.com) located in Parsippany NJ. Focused on distributed technologies such as COM[+], J2EE, and for the past 5 years .NET, SOAP, BizTalk, and Database technologies -- and now WinFX – err, I mean .NET 3.0.

This article is part of the GWB Archives. Original Author: Shawn Cicoria

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.