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:

rename 's/^([0-9]{2})-([0-9]{2})-([0-9]{2})/20$3-$2-$1/g' *.jpg

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"

About kittycatonline.com

kittycatonline.com started out years ago as a site featuring amongst other things, a tribute to Kitty Cat McCollough; one of the nicest, most precious cats dear to me. She was a loving girl who had the patience of a saint. Sadly, she passed on February 29th, 2000. Oh sad day, but perhaps, God willing, she might be waiting in Heaven. Who knows?

Anyhow, kittycatonline.com is the sole work of I, Alan McCollough; unless you see the author is somebody else.  I work at a large hospital in Anchorage, Alaska; but what with folks getting fired for their comments on personal blogs and all; I don't have anything bad to say about my employer. Acutally, I don't have anything bad to say about my employer anyhow. Hey, I'm a happily employed web developer! Why rock the boat?

So, for those of you who are interested, I also produce a television show, aptly named "Kittycat". You can catch Kittycat on Saturday evenings at 9:30 p.m. on GCI Cable channel 9. Consisting of generally whatever I can capture on tape, Kittycat has been on the air for some time now; I am up to episode 27. If you want information on producing public access television, google for "public access television". There ya go.

I consider my Christian faith to be the most important thing I possess in this life, as I do believe that some day I will stand before God and give a full accounting for the life I have lived. Those of you who know me also know that I'm probaby going to be at a loss for words, since I've said and done a ton of things I can't possibly explain away. But then again, when that Day of Judgement comes, I have an advocate who will argue my case for me, amen! You might want to consider this for yourself.

On this site you will find a rather ecclectic wad of topics, so feel free to browse about and leave any comments. Thank you for visiting.

BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.002. Contact Blog Owner