Setting multiple tags to the same value in one command

Started by camner, February 08, 2017, 02:39:47 PM

Previous topic - Next topic

camner

I have a number of tags I'd like to set to the same value (taken from another tag).  I know I can write something like this:
exiftool '-QuickTime:CreateDate<ExifIFD:DateTimeOriginal' '-QuickTime:ModifyDate<ExifIFD:DateTimeOriginal' '-Track1:MediaModifyDate<ExifIFD:DateTimeOriginal' '-Track1:MediaCreateDate<ExifIFD:DateTimeOriginal' '-Track1:TrackModifyDate<ExifIFD:DateTimeOriginal' '-Track1:TrackCreateDate<ExifIFD:DateTimeOriginal' '-Track2:MediaModifyDate<ExifIFD:DateTimeOriginal' '-Track2:MediaCreateDate<ExifIFD:DateTimeOriginal' '-Track2:TrackModifyDate<ExifIFD:DateTimeOriginal' '-Track2:TrackCreateDate<ExifIFD:DateTimeOriginal' FILENAME
but I'm wondering if there isn't a way to set a variable, say, to the source tag content or perhaps to specify multiple target tags without having to repeat the entire thing so many times?

StarGeek

#1
You can create a shortcut tag in your .exif_config file. If you already have a config file, such as the example config, check to see if it already has a shortcut section.  If so, just add the middle line to that section.

%Image::ExifTool::UserDefined::Shortcuts = (
   MyTimeStamps => ['QuickTime:CreateDate', 'QuickTime:ModifyDate', 'Track1:MediaModifyDate', 'Track1:MediaCreateDate', 'Track1:TrackModifyDate', 'Track1:TrackCreateDate', 'Track2:MediaModifyDate', 'Track2:MediaCreateDate', 'Track2:TrackModifyDate', 'Track2:TrackCreateDate']
);


Then you can just do '-MyTimeStamps<ExifIFD:DateTimeOriginal' for all of them.  Of course, you can change MyTimeStamps in the config file to whatever you like.

Shortcuts are also useful to cut down on typing.  For example, rather than try and type out HierarchicalSubject all the time and misspell it constantly, I have a shortcut that reduces it to just HS.

Edit: Fixed config error that camner mentions below.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

camner

Thanks for the quick and clear reply.  I'm having trouble locating the .exif_config file because I'm not sure how to go about searching for a file beginning with the dot character in Windows 10.  And, beyond that, I don't know where to look!

StarGeek

If you didn't create one yourself, you probably don't have one.  You can read the example file I linked above but for quick and easy, just copy the code section in the above post and save it as .ExifTool_config in the same directory that you have exiftool in.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

camner

Great!  Then one final question: How does one create a file with a name beginning with '.' in Windows?  Presumably with the command line?

StarGeek

From Windows, you can't rename a file to add a dot at the beginning, you'll have to go through the command line.  But you can open up Notepad, copy/paste the above example, and save the file as .ExifTool_config
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

camner


camner

Sorry to trouble you again, but I'm having difficulty getting the .ExifTool_config file to work (at all).  The contents of the file are:
%Image::ExifTool::UserDefined::Shortcuts = (
   MyVideoTimeStamps => ['-QuickTime:CreateDate', '-QuickTime:ModifyDate', '-Track1:MediaModifyDate', '-Track1:MediaCreateDate', '-Track1:TrackModifyDate', '-Track1:TrackCreateDate', '-Track2:MediaModifyDate', '-Track2:MediaCreateDate', '-Track2:TrackModifyDate', '-Track2:TrackCreateDate']
);


I placed the file (with no extension) in my Windows folder, because that is where exiftools.exe resides.  I run the command (to read) with:
exiftools -MyVideoTimeStamps FILENAME
I get no output of any kind, nor any error message.

Does the config file need to be manually loaded with -config, or since this is the default name should it auto load?

I also noticed that in your post giving me this code, you omitted the dash ('-') character in front of the first tag name (QuickTime:CreateDate).  I presume that was an error?

I'm sorry if I'm being dense here; I appreciate any help you can provide.

MOL

Quote from: StarGeek on February 08, 2017, 03:41:04 PM
From Windows, you can't rename a file to add a dot at the beginning

What gives you that idea?  Just open Windows Explorer, mark the file you want to rename, and click on it.  Then you can rename it; including a dot as first character.

-Uwe

StarGeek

Sorry, I should have been more specific.  In the context of creating an .ExifTool_config file you can't.   You can't, for example, right click->New->Text Document and then rename that to ".ExifTool_config".  You'll get this error


If there is already a dot in the filename, you can, though.  So, you can create a new text file, name it ".ExifTool_config." (add a dot to the end) and you'll get a a pop up error warning about changing the extension, but the end dot will disappear and you'll have a correctly named ".ExifTool_config".
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

camner

OK, I was able to get this to work!  I used the following ExifTool_config file:
%Image::ExifTool::UserDefined::Shortcuts = (
   MyVideoTimeStamps => ['QuickTime:ModifyDate', 'QuickTime:CreateDate', 'Track1:MediaModifyDate', 'Track1:MediaCreateDate', 'Track1:TrackModifyDate', 'Track1:TrackCreateDate', 'Track2:MediaModifyDate', 'Track2:MediaCreateDate', 'Track2:TrackModifyDate', 'Track2:TrackCreateDate']


Notice that I omitted all of the leading '-' characters in front of the tag names.  For some reason that was the magic bullet!

FWIW, I am using ExifTool in OS X, and perhaps the OS accounts for the different syntax.

Thanks for the help.

StarGeek

Quote from: camner on February 08, 2017, 06:04:44 PM
Notice that I omitted all of the leading '-' characters in front of the tag names.  For some reason that was the magic bullet!

FWIW, I am using ExifTool in OS X, and perhaps the OS accounts for the different syntax.

Sorry, mistake on my part.  I copy/pasted your command line to create the shortcut and didn't edit it completely.  The dashes shouldn't have been there.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Clindor

So.. I basically trying to do the same thing on my side. Lots of my Time Stamps regarding my video files are wrong.

So I created with Notepad a file named ".ExifTool_config" for which I removed the extension and placed where the ExifTool.exe program is.
Inside this file I created two Shortcuts I presumed (one for all the Date of Creation tags with wrong values, the other for all the Date of Modification tags with wrong values). Following is what I wrote inside the file:

%Image::ExifTool::UserDefined::Shortcuts = (MyVideoCreationTimeStamps => ['-FileCreateDate', '-CreateDate', '-TrackCreateDate', '-MediaCreateDate']);
%Image::ExifTool::UserDefined::Shortcuts = (MyVideoModificationTimeStamps => ['-FileModifyDate', '-ModifyDate', '-TrackModifyDate', '-MediaModifyDate']);

Then I execute this Command to make a test on the Date of Modification tags:

ExifTool "-MyVideoCreationTimeStamps<${CreationDate}"  "FILE"

I got the usual error message "No writable tags set" in the output with no modification.

Is it because I tried to create two shortcuts MyVideoCreationTimeStamps and MyVideoModificationTimeStamps and it is not a possible task?

StarGeek

First, don't add dashes to the names in a config file.  Second, you need to put it all in one section.  The second section will override the first one.

This is the sample shortcut section in the example.config file.
%Image::ExifTool::UserDefined::Shortcuts = (
MyShortcut => ['exif:createdate','exposuretime','aperture'],
MyAlias => 'FocalLengthIn35mmFormat',
);


From there, you just want to add your new shortcut commands between the parens
%Image::ExifTool::UserDefined::Shortcuts = (
MyShortcut => ['exif:createdate','exposuretime','aperture'],
MyAlias => 'FocalLengthIn35mmFormat',
MyVideoCreationTimeStamps => ['FileCreateDate', 'CreateDate', 'TrackCreateDate', 'MediaCreateDate'],
MyVideoModificationTimeStamps => ['FileModifyDate', 'ModifyDate', 'TrackModifyDate', 'MediaModifyDate'],
);
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Clindor

Thank you StarGeek for those 2 useful indications!

I followed your advices and put the following text inside the .ExifTool_config file:

%Image::ExifTool::UserDefined::Shortcuts = (
   MyShortcut => ['exif:createdate','exposuretime','aperture'],
   MyAlias => 'FocalLengthIn35mmFormat',
MyVideoCreateTimeStamps => ['FileCreateDate','CreateDate','TrackCreateDate','MediaCreateDate']
MyVideoModifyTimeStamps => ['FileModifyDate','ModifyDate','TrackModifyDate','MediaModifyDate']
);


Then re-tried the Command ExifTool "-MyVideoCreateTimeStamps<${CreationDate}"  "FILE"

And I got a precision in the error message in the output:
syntax error at C:\WINDOWS\.ExifTool_config line 5, near "MyVideoModifyTimeStamps"
(apparently there are no problem with the tags related to the shortcut MyVideoCreateTimeStamps since it's on line 4.

So I double-checked to make sure I haven't misspelled any tag name on line 5 and that every tag I'm using is a tag that appears among the MetaData of the file..
But apparently there is no mistake made on this matter..

So what might be the problem?