conditional renaming and leading 0's

Started by Dendritic, January 28, 2013, 05:00:35 AM

Previous topic - Next topic

Dendritic

Hi,

I want to use exiftool to rename my pictures from various cameras to a fixed pattern:

x x # # # # # y . ext

x x = alphanumerical (to identify camera type, depending on "Model" Metadata (example values : "NIKON D5100" becomes "51", "D800" becomes "D8" )
# # # # # = shutter count of camera with leading 0's (shutter count Metadata if available, else original image number)
y = alphanumerical (color space, depending on "ColorSpace" Metadata (example: "sRGB" : s , "AdobeRGB" : a)
ext = original extension

I understand that to format the shutter count I need to edit the ".config" for a UserDefined but I don't have a clue yet how to bring in my camera type according to metadata.

Help would be appreciated.


Phil Harvey

Here is a thread and here is another where very similar examples are given.  Let me know if you have any questions after looking at these.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Dendritic

#2
Thanks, I had some trouble due to my first steps in what I think might prove as perl syntax ;-)

Here's my complete config, running on 64Bit Windows 7:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyModel => {
            Require => {
                 0 => 'EXIF:Model',
            },
            ValueConv => '$val[0]',
            PrintConv => {
                'NIKON D5100' => '5A',
                'NIKON D800' => '8D', # escaping required for 8D, not for D8
            },
         },
         MyColorspace => {
            Require => {
              0 => 'ColorSpace',             
            },             
            ValueConv => '$val[0]',
            PrintConv => {
                '1' => 's', # Unknown (1) = sRGB
                '2' => 'a', # Unknown (2) = Adobe RGB, see Nikon Tags at http://www.exiftool.org/TagNames/Nikon.html
                0xffff => 'a', # Unknown (65535) = Adobe RGB - for JPG's it is either '1' or '65535', which translates to Uncalibrated / Unknown (-1) - in this case my cameras did AdobeRGB
            },
         },
         MyShutterCount => {
            Require => 'ShutterCount',
            PrintConv => 'sprintf("%.5d", $val)'
        },
    },       
);


exiftool _DSC9192.NEF tells me:

Shutter Count                   : 21841
Color Space                     : Adobe RGB
My Colorspace                   : Unknown (2)
My Model                        : 5A
My Shutter Count                : 21841

works fine now:
exiftool "-filename<${MyModel}$MyShutterCount$MyColorSpace.%e" _DSC9192.NEF
but I wonder when to use ${MyModel} instead of $MyModel.


Phil Harvey

You only need to put braces around the tag name if the character immediately after the name is 0-9, A-Z, a-z, _ or -.  In your case it is "$", so the braces are not necessary.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).