Use a second Tag when the first is not available

Started by JanK, June 20, 2012, 07:56:16 AM

Previous topic - Next topic

JanK

Hi

normal I use this tag
exiftool '-filename<NameOfEvent_${datetimeoriginal}_%1.4C_Fotograf.%e' -d %Y-%m-%d -ext jpg -ext avi -ext mov -fileorder datetimeoriginal# DIR

So on my iPhone Video (.mov) has no datetimeoriginal. Instead it has "CreateDate-deu" which is the time of the video.

Question
How can use the "CreateDate-deu" instead of "datetimeoriginal" for files which has no "datetimeoriginal"?
Consider there are different files in a folder which has a "datetimeoriginal" and some has only a "CreateDate-deu". I took photos from different camers but for the same event. And now I will bring all in the right order and with correct filenames.
-Mac OSX Mountain Lion-

Phil Harvey

The answer is simple:  Set the FileName twice on the command line.  If both dates exist, the 2nd will take priority.  If only one exists, the FileName gets set from it.

- 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 ($).

JanK

You mean in one command? And what happen to the -fileorder?

Is this right?
exiftool '-filename<NameOfEvent_${datetimeoriginal}_%1.4C_Fotograf.%e' '-filename<NameOfEvent_${CreateDate-deu}_%1.4C_Fotograf.%e' -d %Y-%m-%d -ext jpg -ext avi -ext mov -fileorder datetimeoriginal# -fileorder CreateDate-deu# DIR

Edit:
Maybe not. It puts the mov at the end of all files. ???
-Mac OSX Mountain Lion-

Phil Harvey

Sorry, I didn't notice the -fileorder.  That is a bit of a problem.  To handle this you would need to make a user-defined Composite tag which is based on both of the date/time tags and takes the one that is available.

- 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 ($).

JanK

I did not find any information how to do that.
Can you give me a link explaining this way.
-Mac OSX Mountain Lion-

Phil Harvey

Here is the sample config file that explains the basics and gives some examples.  Your config file will look something like this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyDate => {
            Desire => {
                0 => 'DateTimeOriginal',
                1 => 'CreateDate-deu',
            },
            ValueConv => '$val[0] or $val[1]',
            PrintConv => '$prt[0] or $prt[1]',
        },
    },
);
1; # end


Then use the MyDate tag in your command instead of the other tags.

- 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 ($).

JanK

Works great. Thanks!

I read so much but I'm not sure.

"Desire": At least ONE of the following tags MUST exists. I understood that.
But what means "ValueConv" and "PrintConv"?
And in which order are the tag names used? What happen when both exists? Will it use the last one (1)?
Can you please explain me the two lines?
-Mac OSX Mountain Lion-

Phil Harvey

In this case, the "or" expression returns the first value that exists.  ValueConv returns the value you see with the -n option (or -MyDate#).  The PrintConv value is the formatted value you are using in the FileName.

- 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 ($).

JanK

Thank you very much!

This helps a lot. I have several pictures which are not using the datetimeoriginal. Most time this is a video from telephone cameras. So with this I can write all the date tags in my pictures/videos in this config file and can handle all my files in the same way.

Wonderful!
-Mac OSX Mountain Lion-

JanK

Hi Phil!

I dropped the "Exiftool_config" in "/usr/bin"

In some cases it will not work

  • I leave the name "Exiftool_config"
  • I create an Alias named "Exiftool_config"
  • I create an Alias named ".Exiftool_config"
The only way it works is

  • The origin file named ".Exiftool_config"

Question
Why is it not working with an Alias? I like to store the origin config file in a special user folder without a dot (.) because of my organization structure.
-Mac OSX Mountain Lion-

Phil Harvey

Try making a soft link instead of an Apple alias:

ln -s MY_CONFIG_FILE ~/.ExifTool_config

Putting the config file in your home directory (~) is the preferred method for a single user.  I would only put it in /usr/bin if you want it to be the default for all users on your system.

Alternatively, you can put it wherever you want and set the EXIFTOOL_HOME environment to point to the directory.

- 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 ($).

JanK

Hi!

I have some problem with fileorder it does not work.

exiftool '-filename<Eventname_${MyDate}_%1.4C_.%e' -d %Y-%m-%d -ext jpg -ext avi -ext mov -ext wmv -fileorder MyDate# DIR

with MyDate

# Exiftool Config File

####### Date/Time je nach Verfügbarkeit in der angegebenen Reihenfolge verwenden ##############
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyDate => {
            Desire => {
                0 => 'DateTimeOriginal',
1 => 'CreateDate',
2 => 'CreationDate',
                3 => 'CreateDate-deu',
            },
            ValueConv => '$val[0] or $val[1] or $val[2] or $val[3]',
            PrintConv => '$prt[0] or $prt[1] or $prt[2] or $prt[3]',
        },
    },
);
#------------------------------------------------------------------------------------
1; # end


The composite tag of a movie gave me a date that is before other files in the folder. But it is listed after them after executing.
-Mac OSX Mountain Lion-

Phil Harvey

Could you post the output of this command for 2 of the files that are out of order?:

exiftool -d %Y-%m-%d -filename -mydate -mydate# FILE

Thanks.

- 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 ($).

JanK

I'm sorry!

Yesterday I set DateTimeOriginal of jpg's back to 3 minutes but forgot to reset the FileModifyDate. So in Finder it seems that the video files are in the wrong order. Sorry! Everything is right. No malfunction. 
-Mac OSX Mountain Lion-