This is a Nodejs port of my original script written in Ruby. Currently it provides around 80% of the functionality of the original, and everything that I needed for my personal use. The plan is to deprecate the Ruby script since I am now mostly working in Nodejs and are much more capable in that language.
The only dependency is for the script is that
npm be installed. Other depenedencies will be automatically installed by
To install the script itself:
npm install photo_rename
What the script does
This script is fairly specific. It renames all JPG files (technically files with a .jpg or .jpeg extenstion) in a given directory to the form
The naming pattern described above is the naming pattern used by the stock Android camera. Renaming photos taken with other devices to this scheme allows me to seamlessly merge photos into a single directory and maintain consistent file names.
Changing the image date
It is quite common (at least for me) that my camera time is incorrect. This happens most often to me when traveling to a different time zone.
Although I started implementing this functionality into the app, I decided to stick to the Unix philosophy of letting the app "do one thing well". There are many different tools that are better suited to changing an image's exif data. Personally I use jhead. It does everything I need and is simple to learn.
Lets look at an example:
If I take my photos while in
EST, but my camera was set to
CST, I have to adjust the time forward with 1 hour.)
jhead -ta+1:00 ~/my_photos/*
Then I run
photo_rename on the same directory
Or if you want to do it all in one command:
cd ~/my_photos && jhead -ta+1:00 * && photo_rename
Renaming RAW files
v0.1.6 of the app you can rename corresponding
RAW files (or any file really) together with the
RAW file extensions seem to vary quite a lot, you need to specify the file extension for your particular case. The algorithm will look for files with that extension that have the same base name as a
JPEG file. These two files will be renamed together with the new date based name.
For example, lets say my camera created the following two files after I take a photo:
Given the following command:
photo_rename -e RW2 .
will result in the files being renamed as:
This program is licensed under GNU GPL