Multi-file rename with linux., Or, Using linux to rename photos from my Motorola RAZR.
I have a Motorola RAZR cellphone. Nowadays this is a positively old phone, but I still use it. I got a utility to download the photos to my PC, but unfortunately, the images are labeled in DD-MM-YY_####.jpg format. Also, the utility I use to get photos off of my phone, well, all the file dates come out as 1969.
So, for a photo taken July 31, 2009; it is labeled 31-07-09_1234.jpg. Doesn't sound like a problem until you try to sort them. What a pain. I see no way to change the auto naming on the phone, either.
The problem? Photos are named DD-MM-YY_####. The desired result? Rename them in YYYY-MM-DD_#### format. So what's the solution? Well, I happen to have a server running Ubuntu Linux, so the solution to fixing the file dates is a one-liner.
I copy the files to a directory on my server, get a terminal session started, navigate to the directory with the photos, and issue this command:
Unlike the 'rename' command in other flavors of linux, the Ubuntu version uses regular expressions (aka "regex") to do the rename. This particular regex shuffles the DD-MM-YY format to YY-MM-DD, and plops a "20" in front of the year, to turn a "09" into a "2009". The 'rename' command itself is applied to all files in the current directory ending in ".jpg"


