ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mjb on May 04, 2024, 04:57:06 AM

Title: copying datetime tags between images with different names in same folder
Post by: mjb on May 04, 2024, 04:57:06 AM
Hello

I have a subfolder of jpgs called 'images' from which I've been extracting trailer jpg files using:

exiftool -trailer -b -W %d%f_trailer.%e  images -ext jpg

I end up with the original jpgs and their '_trailer.jpg' all in one folder which is great.


How can I then copy all date/time tags from the originals to their counterparts within the folder?

I've been trying to use -tagsfromfile but have been going round in circles with the syntax. For example, here's
one failed attempt:

exiftool -tagsfromfile %d%f.%e -All:Alldates -ext jpg ... images -if "$Filename=~ /trailer/"

Any help greatly appreciated. Thanks.

mjb

OS: Windows 10 Home
ExifTool: 12.84

Title: Re: copying datetime tags between images with different names in same folder
Post by: StarGeek on May 04, 2024, 10:05:33 AM
Quote from: mjb on May 04, 2024, 04:57:06 AMI've been trying to use -tagsfromfile but have been going round in circles with the syntax. For example, here's
one failed attempt:

exiftool -tagsfromfile %d%f.%e -All:Alldates -ext jpg ... images -if "$Filename=~ /trailer/"

You are very close with this. The %f variable has the base filename of the file being processed, in this case, the trailer file.  In order to convert the trailer filename back to the original, you have to remove "_trailer", i.e. the last 9 characters of the name. The Advance Features section of the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) details how this is done.

exiftool -tagsfromfile %d%-.9f.%e -Alldates -ext jpg ... images -if5 "$Filename=~ /trailer/"

In %-.9f, the - indicates starting at the end of the text, and the .9 indicates removing 9 characters.

All you probably need to use is -AllDates instead of -All:AllDates unless you know that there are XMP time stamps in the file that you want to copy as well.

Using -if5 will speed up processing a bit as this tell exiftool just to check only the file system tags for the if statement instead of extracting all the data. See the -if option (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR).
Title: Re: copying datetime tags between images with different names in same folder
Post by: mjb on May 04, 2024, 10:11:50 AM
Update

Think I've found a solution by referring to the solution by StarGeek in this post by Thomas:

https://exiftool.org/forum/index.php?topic=15988.0
Don't know if it's the best method, but this appears to do what I want:

exiftool -tagsfromfile %d%-.8f.%e -All:Alldates -ext jpg images -if "$Filename=~/trailer/"

This is what I was missing:

%-.8f

ie, derive original filename by removing the 8 character '_trailer' suffix from the target filename

Regards

mjb


Title: Re: copying datetime tags between images with different names in same folder
Post by: mjb on May 04, 2024, 10:18:07 AM
Thanks StarGeek for your post. Was busy posting mine when you sent yours.

Thanks for the tips re -AllDates and -if5. Will use them from now on.

If I may ask another question, I just tried the command without the ... and it seemd to work OK.
I just used it because I found it somewhere in the forum.

Bu what does the ... actually do? Do I need it?
Title: Re: copying datetime tags between images with different names in same folder
Post by: StarGeek on May 04, 2024, 10:36:23 AM
The "..." was probably just ellipses, meaning putting in any other options needed.  Since it was after the -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension), just a placeholder for more of that e.g. -ext png -ext tif.

The dot by itself means to process the current directory, so you'll need one if you are in the correct directory and don't provide any other directory path.
Title: Re: copying datetime tags between images with different names in same folder
Post by: mjb on May 04, 2024, 12:20:07 PM
OK, that's great.

All sorted now.

Thanks very much for your help.

Regards

mjb