News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

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?

Phil Harvey

You need commas at the ends of the lines that you added.

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

Clindor

#16
Quote from: Phil Harvey on February 26, 2020, 01:20:38 PM
You need commas at the ends of the lines that you added.

- Phil

Oh.. what is a shame is that StarGeek already corrected it for me in his previous post  ^^'
Thank you.

Last question on this matter if I may (but not least): The command can now be executed.
But it modified the type of the file on which the Command has been applied in the process.
The extension for this file is now "MOV_original" instead of "MOV". Why did it happen?

Needless to say that now the file cannot be recognized by VLC or be read..  :'(

Phil Harvey

After running the command on FILE, the file with name FILE should be updated, and the original is preserved as FILE_original.  Add -overwrite_original to the command if you don't want to save the original.

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

Clindor

Quote from: Phil Harvey on February 26, 2020, 02:01:16 PM
After running the command on FILE, the file with name FILE should be updated, and the original is preserved as FILE_original.  Add -overwrite_original to the command if you don't want to save the original.

- Phil

Will it modify the file in any other way than replacing the 4 Tags' wrong values with the value I'm interesting in?

Clindor

#19
Actually there are different elements that make me think I might be using the wrong tool for what I need:

Why is there any need to overwrite the whole video file while I only need 4 tags to be affected by one good value coming from a fifth tag ?

By applying the command ExifTool "-MyVideoCreateTimeStamps<${CreationDate}" "-overwrite_original" "FILE", then the Command Exiftool -s "FILE" to list all the MetaData, I first thought the Command just erased one of the 4 affected tags (CreationDate), then I realized it was placed in a totally different spot than usual in the list..

Can you just change the values of 4 tags (by a common value) without having to copy the entire file or overwriting it?

What I really wanted is the instruction -MyVideoCreateTimeStamps<${CreationDate} to replace the four instructions -FileCreateDate<${CreationDate}, -CreateDate<${CreationDate}, -TrackCreateDate<${CreationDate}, -MediaCreateDate<${CreationDate}, but if that's not possible, I think I'd gladly put those 4 instructions in my command instead  :) rather than having to copy or overwrite each of my Video files (which can take quite some time when it comes to video, in addition to modifying the structure/organization of the MetaData which is also unwanted in my case...)

Phil Harvey

Sorry, there is no way to do what you are asking with ExifTool.

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

Clindor

Alright, thank you for this clarification.

I'll put the 4 instructions instead of one in my "super-command" then.  :)

Phil Harvey

Sorry, I was responding to this (before you edited your post and asked the last question):

QuoteCan you just change the values of 4 tags (by a common value) without having to copy the entire file or overwriting it?

To which the answer was no.

But To answer this:

QuoteWhat I really wanted is the instruction -MyVideoCreateTimeStamps<${CreationDate}

Yes, this should work.

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

Clindor

Yes, I AM sorry actually, because I'm the one editing a lot ^^' My apologies

What I meant is that by putting the 4 instructions in one command:
ExifTool "-FileCreateDate<${CreationDate}" "-CreateDate<${CreationDate}" "-TrackCreateDate<${CreationDate}" "-MediaCreateDate<${CreationDate}" FILE
..there will be no overwriting or copying of the whole file (just values being replaced in the MetaData).

I thought that with ExifTool "-MyVideoCreateTimeStamps<${CreationDate}" FILE could do the exact same with a shorter command  :) .. but that is no big deal  ;D I was just trying to optimize the whole thing here

StarGeek

Using the four separate tag copies is exactly the same as using the shortcut.

ExifTool will always create a new file and replace the old one with the new file.  Exiftool never edits "in place".  Which, if you think about it, is a bad idea in the first place.  If there's a power failure or some other interruption during the write, the whole file could be corrupted.
* 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

OMG, I have never noticed that!... Why is ExifTool making a copy when I put 4 instructions at the time, and apparently NO copy when I ask for only ONE modification at the time?? :-o

StarGeek

FileModifyDate and FileCreateDate will not create a new file because those tags are part of the underlying OS.  Changing those doesn't edit the original file, it just edits the entries in the file system data for that file.  The same way that renaming a file doesn't change the file itself.

All of the other tags will require exiftool to create a new file.
* 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


Clindor

Regarding the "-overwrite_original" option, did I put it on the right spot inside the command?:

Quote from: Clindor on February 26, 2020, 02:58:54 PM
ExifTool "-MyVideoCreateTimeStamps<${CreationDate}" "-overwrite_original" "FILE"

StarGeek

It can be almost anywhere in the command.  Just as long as it doesn't break up an option that requires a second parameter, like the -d (dateFormat) option.
* 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).