Saturday, April 13, 2013

Using exiftool to rename pictures from digital camera

Lots of pictures taken with digital camera (including the ones in smartphones)... so I need a way to at least easily identify when a particular picture is taken, and exiftool comes in handy.

First, create a file named .ExifTool_config at user's root directory containing something like the following:


%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyModel => {
            Require => 'Model',
            # translate spaces to underscores
            ValueConv => '$val =~ s/Canon DIGITAL IXUS v2/IXUSV2/; $val =~ s/KODAK DX4330 DIGITAL CAMERA/DX4330/; $val =~ s/C860L,D360L/C860L/; $val =~ s/Canon IXY DIGITAL 320/IXY320/; $val =~ s/ |-//; $val =~ s/(.*)/uc($1)/e; $val',
        },
        MyMake => {
            Require => 'Make',
            # translate spaces to underscores
            ValueConv => '$val =~ s/EASTMAN KODAK COMPANY/KODAK/; $val =~ s/OLYMPUS OPTICAL CO.,LTD/OLYMPUS/; $val =~ s/CASIO COMPUTER CO.,LTD/CASIO/; $val =~ s/ |-//; $val =~ s/(.*)/uc($1)/e; $val',
},

    },
);
1;  #end

Then run the following command:


exiftool -d %Y%m%d-%H%M%S '-FileName<${CreateDate}-${mymake}${mymodel}.%e'

File names of images files on will become like the following:

20040228-133116-CASIOEXS20.jpg

Use "c" to add counter, like below:

exiftool '-FileName<${DateTimeOriginal}_$Model.%e' -d %Y-%m-%d_%H-%M-%S%%-.c 

Rerences:
http://www.sno.phy.queensu.ca/~phil/exiftool/
http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q11