Rename photos in bulk using EXIF data contained within

I like to have my photos organized into chronological order. So I sort them in folders by year, month and name of the event. Even within the event folders, I like to have the filenames reflect information about photograph. For example, when the photo was clicked, where it was taken, what equipment was used etc.

Lightroom does a very good job of renaming the imported RAW files and exported JPGs using EXIF information that’s encoded into the photographs. But all my photos from my smartphone, my wife’s smartphone end up having messy filenames like IMG00923.JPG or DSC_000_175.JPG etc. These photographs have EXIF information too that can be used, it’s just needs to be extracted. So I wrote this little tool, which can help me achieve this.

It’s called smart-image-renamer. What it does is – go through my entire photo library (or whatever photos I want to rename) and rename all the photos using a format I provide. The format can have things like year, month, date, time, camera, lens, name of event, name of folder etc. For example, let say I went to Half Moon Bay with family and I have a bunch of photos I want to rename. I will write the format as {YYYY}{DD}{MM}{Model}_Half-Moon-Bay{Seq} and these tags within {} are replaced by relevant data stored in the EXIF. So resultant filenames for the photos would look like:

20140529_LGE Nexus 5_Half-Moon-Bay_001.JPEG

20140529_LGE Nexus 5_Half-Moon-Bay_002.JPEG

That’s just one example. There are few more tags that can be used out of EXIF information to rename photos. smart-image-renamer has a nifty test mode too, so that you know what it will do without actually affecting the photos.


Best way to download smart-image-renamer is using pip.

$ pip install smart-image-renamer

Or you can download smart-image-renamer as zip from it’s Github page and install it like any other python package.

$ python install

I plan to introduce more functionality in future. Let me know if you’d like anything in specific. Feedback on smart-image-renamer is always welcome.

Auto Update Script For Plugins Not Hosted On

Auto Update script for WP Plugins not hosted on

This script can be used for WordPress plugins that are not hosted on It works transparently for users providing same experience as if the plugin was hosted on is a very capable platform for plugin/theme developers to host their creations. There are many advantages of hosting your plugin on, for example –

  • Exposure to millions of WordPress users without actually spending anything on advertising
  • An easy source control repository option – subversion
  • Automatic release management and automatic updates to users
  • Automatic web-page generation for the plugin using simple to write README
  • Download statistics for the plugin
  • A very good rating system too

However, recently WordPress has become very strict on licensing of code uploaded on their repositories. They no more allow you to use any code that is licensed under Creative Commons. This is a big problem for me as I’m using a third-party tool licensed under creative commons, and many of my users were dissapointed when I had to remove this tool from my plugin.

So, I decided to host my plugin somewhere else to be able to use code licensed under creative commons. The most important aspect of this decision is that, I’ll loose ability to provide auto-update for my plugins. Then I came across this excellent script written by Kaspars. It allows you to setup auto-update mechanism for your plugin which is not hosted on

When I started using this script, I realized that there is huge potential in this script to be useful for many more WordPress developers like me. So I developed this script further to make it easier to deploy and added more features to it, for example –

  • Serve multiple plugins using same script
  • Serve different types of versions like stable, alpha, beta, lite, pro, test etc.
  • Easy to configure ini file

I plan to add some more features to this script in future, so I uploaded the same on as a project.

Visit the project page of this script on to download this script or get more details.

Mac OS X’s Dumb Copy/Paste

Yesterday I was copying some movies from one external hard-disk to another on my MacBook Pro running Snow Leopard (Mac OS X 10.6.7).  Totally it had to copy about 240 GB of data and it would take 2 hours to copy all the files, so I started the copy overnight.  What I see in the morning is an error which says “An error occurred trying to read blah-blah”.  The dialogue box only had an OK button.  When pressed it, it just closed the copy operation and I was left with a partial copy of data with absolutely no clue how many files were copied and where exactly the stupid thing stopped copying.

Now how difficult can it be to just skip the corrupted file and continue copying rest of the content?  But no, the developers at Apple decided to implement it the stupid way.

Things were OK till I realized another dumbness of Mac OS X’s copy/paste.  If you want to copy a folder and merge it with another folder with same name, you can’t do it on Mac OS X.  Take this example, I have two folders named Movies in two separate hard-disks disk1 and disk2.  Now I want to merge them in disk2, so I just copy the Movies folder from disk1 and paste it on disk2.  I would expect that all my files on disk2 will be preserved and additional files from disk1 will be copied over.  But again a BIG NO.  Dumb Mac OS X will delete all the files under Movies on disk2 and replace them with files on disk1.

How dumb is that !!!

BTW, Linux copied the *corrupted* files perfectly fine and I can play those movies without a hitch.  Go figure.

Passing PHP Array To JavaScript Using wp_localize_script()

If you are looking for a generic way to pass a PHP variable to JavaScript, please move on.  This post is specific to WordPress plugins.

If you don’t know how to pass a PHP variable to JavaScript for your WordPress plugin, go through this very good post by Otto – Passing parameters from PHP to Javascripts in plugins This is a very safe and straightforward way to pass your PHP variables into your JavaScript.

This works perfectly fine if your variable is NOT an ARRAY.  So, if you want to pass your PHP arrays to your JavaScript, you’ll have to do a bit more, but it is still pretty much straight forward.  Here are the steps –

  1. Encode your PHP array using json_encode()
  2. Pass the encoded array to your JavaScript using wp_localize_script()
  3. Parse the JSON encoded data in JavaScript back to a JSON object

Ain’t it simple?  Let’s take one example. Here’s how my sample PHP array looks like –

$my_arr = array('my array',
'name' => 'Ronak',
'surname' => 'Gandhi',
'phone' => array(
'home' => 12345,
'office' => 67890),
'hobbies' => array(

Now we need to encode this array into JSON string.

$my_json_str = json_encode($my_arr);

json_encode() serialized PHP arrays into strings. If you print the encoded string, it will look like this –

{"0":"my array","name":"Ronak","surname":"Gandhi","phone":{"home":12345,"office":67890},"hobbies":["photography","programming","driving"]}

Now that our array is a PHP string, we can pass it to JavaScript using wp_localize_script().

$params = array(
'my_arr' => $my_json_str,

wp_localize_script(‘my-java-script’, ‘php_params’, $params);

Next step is to parse the JSON string back to a JSON object in JavaScript. Our PHP array passed using wp_localize_script() is available in JavaScript as php_params.my_arr.  If you check the string value of php_params.my_arr, you will see lot of quot; amp; etc.  So first we need to replace those escaped characters.  If you have other such characters in the string, you’d have to replace them too.

/* Before replacement
{"0":"my array","name":"Ronak","surname":"Gandhi
var my_json_str = php_params.my_arr.replace(/"/g, '"');
After replacement
{"0":"my array","name":"Ronak","surname":"Gandhi","phone":{"home":12345,"office":67890},"hobbies":["photography","programming","driving"]}

Now we can safely parse this string and convert it into a JSON object.

var my_php_arr = jQuery.parseJSON(my_json_str);

Once this is done, we can access my_php_arr as any other JSON object. Parameters can be accessed as my_php_arr[‘name’], my_php_arr[‘surname’] etc.

Awesome Flickr Gallery Goes Live. Check It Out !!!

Awesome-Flickr-Gallery LogoI was working on a Flickr gallery plugin for WordPress since a week.  I have finally released it now.  The plugin enables you to integrate your Flickr photo-stream with your WordPress enabled website.

Well, you must be thinking there are probably hundreds of such plugins already available then why write one more.  Actually I wasn’t satisfied with any of the current Flickr gallery plugins.  They lacked something or the other I wanted.  Don’t misunderstand me here – all of them are really great in their own way but none fit my needs.  So I decided to write one on my own.  To be honest, I wanted to do some side project to learn something new.  I got to learn PHP, Javascript and SVN.

The plugin now is still has only basic functionality.  I plan to take it to next level where it can compete with other Flickr gallery plugins.  I have created a dedicated page for this project, check it out.

Are You A Fan Of Keyboard Shortcuts? Try Vimperator For Firefox

Do you like to use keyboard shortcuts for faster navigation in applications like editors, browsers, media players, etc?  I use them a lot for navigating through applications like, GMail, Firefox, Movist, Picasa to name a few.  Keyboard shortcuts help a lot in avoiding mouse usage which in turn speeds up the process as you don’t have to stretch out to your mouse or touch-pad every-time you want to do something.  If you fall in this category too then you will love Vimperator. Continue reading “Are You A Fan Of Keyboard Shortcuts? Try Vimperator For Firefox”