Sometimes you may store a lot of photographs after a nice trip to somewhere, or due any social event and once you arrive at home and start transferring your photos, you may end up with a dilemma: the weird file name of the photos. Most of the camera uses the classic DSC_###  or the IMG_### label, none of these labels helps you to keep a good track of which photo represents a certain activity, here is an example of a typical folder with some pics:

 

Example of some pictures

 

Just imagine, these pics represents your “2008 wedding party” and you want to save them in folder with other pics with similar label, in the end it will be a total mayhem. A quick solution could be just creating a different folder with a “representative name” but if you want a geek approach, let’s develop a bash script to perform a rename over these pics.

Prepare the label

Now, we want a special label for these pics, let’s use the label “2008_wedding_p_“, this will be the prefix for this pics, every file will start with prefix and we will add a number after it for each file, i.e, 2008_wedding_p_1, 2008_wedding_p_2, 2008_wedding_p_3 and so on…

The magic starts

Now let’s create the script called “fileRename.sh” as follows:

Now, just create the file inside any folder with pics and execute it, you will see the renaming in action:

Result of the script

Tested on Windows (Using cygwin), Ubuntu 13.04 and Mac OS X (Mavericks)

Follow me

Carlos Alberto Umanzor Arguedas

Web Developer at carlosumanzor.com
Web Developer, QA Engineer and Gamer Enthusiast, Developer of Linkcrawler and Father of a future computer ninja.
Follow me

 

 

Pin It on Pinterest

Shares
Share This
Optimization WordPress Plugins & Solutions by W3 EDGE