Assign the same value to multiple tags

Started by Androne, October 23, 2022, 06:29:42 PM

Previous topic - Next topic

Androne

Is there a quick way to assign the same value to multiple tags? I was thinking something similar to how in C, you can do the following:

int a, b, c;
a = b = c = 0;

to assign 0 to a, b, and c. I tried something like this with exiftool:

exiftool -quicktime:*createDate<quicktime:*modifyDate="2022:01:01 00:00:00-05:00"

But it didn't work. What's the proper way to do this if it exists?

Androne

I should also add that my main use cases for a feature like this would be:

  • Assigning the same value to the quicktime:*createDate and quicktime:*modifyDate tags
  • Assigning the same value to ifd0:orientation and ifd1:orientation, because doing
    -all:orientation#=6 doesn't set the ifd1 tag

If there's a workaround for those two scenarios, that would help me as well.

StarGeek

If you use a wildcard (?/*) in the tag name (not the group name), you can set multiple tags that way.  For example, GPSLatitude/GPSLongitude have matching GPSLatitudeRef/GPSLongitudeRef tags that also need to be filled in order to give the N/S/E/W direction.  In those cases you can use
-GPSLatitude*=40.6892 -GPSLongitude*=-74.0445
to quickly fill all four tags.

If there isn't anything that you can wild card, then your other option is to create a shortcut in the .exiftool_config file. The AllDates tag that you see often on these forums is such a tag.

A short cut is pretty easy to create.  If you look at the example.config file, right at the top you'll see
%Image::ExifTool::UserDefined::Shortcuts = (
    MyShortcut => ['exif:createdate','exposuretime','aperture'],
    MyAlias => 'FocalLengthIn35mmFormat',
);

This creates two shortcuts named MyShortcut, which is composed of the exif:createdate, exposuretime, and aperture, and MyAlias, which is a shortcut for FocalLengthIn35mmFormat.  Note that in the first case, only exif:createdate contains a group name.  For the other two, the value can be pulled from any tag with that name or list all of them if the -a (-duplicates) option is used.

A couple of examples from my config file 
HS => 'HierarchicalSubject',
MyLong => ['GPS:GPSLongitude', 'GPS:GPSLongitudeRef', 'XMP:GPSLongitude'],
MyLat => ['GPS:GPSLatitude','GPS:GPSLatitudeRef','XMP:GPSLatitude'],
SysTime => ['FileCreateDate','FileModifyDate'],

The first one is just an alias because I don't like typing out HierarchicalSubject.  The second two fill out both the EXIF GPS tags and the XMP GPS tags.  The last is a short cut for the file system tags.

In your first case, I'm assuming you want to fill out all the TrackCreateDate/TrackModifyDate/MediaCreateDate/MediaModifyDate tags at once.  Expanding on the example you list,
-quicktime:*CreateDate="2022:10:23 12:00:00" -quicktime:*modifyDate="2022:10:23 12:00:00"
will actually do that, as well as fill the the Quicktime:CreateDate/Quicktime:ModifyDate.

In the case of Orientation, because the Orientation tag would be non-standard in the IFD1 group, you would have to use a shortcut to force creation/editing in that location.
%Image::ExifTool::UserDefined::Shortcuts = (
    My Orientation => ['Orientation','IFD1:Orientation'],
);
In the first case, using just Orientation will edit the IFD0:Orientation, as well as any other Orientation tags that are in standard places, such as the PanasonicRaw:Orientation tag.  IFD1:Orientation will force editing/creation of Orientation in the IDF1 group.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Androne

Thanks for the reply, I'll use shortcuts for the quicktime tags.

I only modify the IFD1:orientation tag for images that already have it. I'd rather have the orientation tag in IFD0 and IFD1 match rather than only change it in the IFD0 group. However, since you said it's non-standard, I'll consider just removing that tag from images that have it. Do you know if there's a specific command for removing the non-standard IFD1 tags? Or will I have to identify them individually and set them to be blank?

I don't want to just do "-IFD1:all=", however, in case there are tags there that aren't in the IFD0 group.

StarGeek

Quote from: Androne on October 23, 2022, 09:01:25 PMDo you know if there's a specific command for removing the non-standard IFD1 tags? Or will I have to identify them individually and set them to be blank?

Pretty much identify them individually.  Or you could just ignore them unless they actually give you some problems in some software.  They're not very common and usually only exiftool will see them.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford

Wouldn't -execute do it?  Something like:

exiftool modifyDate="2022:01:01 00:00:00-05:00" -execute -createdate=modifydate FILE

Sorry if the syntax is incorrect - I haven't tried it.

StarGeek

The command would have to be
exiftool modifyDate="2022:01:01 00:00:00-05:00" -execute "-createdate<modifydate" -common_args FILE

But the thing to remember about the -execute option in this case is that it's no different than running separate commands
exiftool -modifyDate="2022:01:01 00:00:00-05:00" FILE
exiftool "-createdate<modifydate" FILE

In this case, it would take longer because exiftool is running twice over the same files.  Quicker to just assign both tags in the same command.
exiftool modifyDate="2022:01:01 00:00:00-05:00"  -createdate="2022:01:01 00:00:00-05:00" FILE

IMO, -execute is rarely useful combining a small number of commands.  It adds complexity and makes thing harder to troubleshoot.  I rarely use it except in a few cases where I have the command correct and use it with an autohotkey text replacement.  And to be honest, those probably would be better used by creating an -@ (Argfile) option.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype