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
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).
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
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?
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.
OK, that's great.
All sorted now.
Thanks very much for your help.
Regards
mjb