Elton Stoneman

  Home  |   Contact  |   Syndication    |   Login
  85 Posts | 0 Stories | 199 Comments | 0 Trackbacks

News

Archives

Post Categories

Smart Rename is a little tool I put together a while back and have found pretty useful – it's up on CodePlex here: Smart Rename.

It lets you rename files in bulk, based on a pattern you provide:

It should be fairly self-explanatory, but in case not: anything in the pattern flagged with %...% will be evaluated for each file in the list and replaced with a computed value. Arguments can be passed to the computing component with the syntax %replacement%{arg1:arg2}. You can preview the new name before making any changes, and when you commit it will report whether it was successful at renaming each file.

One frequent use is for changes to project names halfway through development. So when Project Tango becomes Project Sierra, you can use %string%{Acme.Tango:Acme.Sierra} to rename C# projects with names like Acme.Tango.Entities.csproj. Or if you want to prefix filenames with the folder they're in and suffix them with the current date, you can do it with %folder%_%filename%_%date%. Some of the replacements available look odd, but I've had a use for them all at some time. By default SmartRename retains the original file extension, but you can override that to change extensions too.

Technically there isn't much to it. Replacements are evaluated through classes which implement IReplacement and are configured using Castle. Currently the following are provided:

Adding new replacement functionality is very simple, just a case of implementing the IReplacement interface (or extending from ReplacementBase) and adding the class as a component in the app config.

posted on Thursday, June 19, 2008 10:30 PM

Feedback

# re: Smart Rename tool on CodePlex 7/29/2009 11:08 AM Matthew
Powerfully awesome tool! It just saved me hours in testing a bulk process. Your tool completely made my day! Thank You so much for making this available.

# re: Smart Rename tool on CodePlex 7/29/2009 1:38 PM Elton
Glad to hear it was helpful for you Matthew, thanks very much for your comment.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: