Randomly Mental ™

My Online Junk-Drawer of Blogging Miscellany ™

Regular Expressions (Date Matching and Conversion) – Perl 5 and Bulk Rename Utility.

Posted by kristobaldude on December 26, 2009

12/26/09

Regular Expressions (Date Matching and Conversion) – Perl 5 and Bulk Rename Utility.

I occasionally find myself modifying my digital photo naming convention, and subsequently end up having to rename a lot of photos (thousands!). The best program that I have found for renaming is called Bulk Rename Utility (BRU)

Bulk Rename Utility utilizes/supports the Perl 5 regular expression conventions. In other words, any syntax that works in Perl 5 should also work in BRU.

Here is the code for matching dates in the format “mm-dd-yy”:

^(\d{2})-(\d{2})-(\d{2})(.*)

Here is the renaming portion which uses the extracted elements

(e.g.: \1 = element 1, \2 = element 2, etc.)

to rename date in the format “yyyy.mm.dd”:

20\3.\1.\2

NOTE: If using the filenaming convention:

<DATE>_<DESCRIPTION>

, after modifying the date portion, to add on the remaining part, just add the “\4” element directly onto the end of the replace statement like this:

20\3.\1.\2\4
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: