ExifTool Forum

ExifTool => Newbies => Topic started by: colacounty on December 05, 2021, 01:20:38 PM

Title: -tagsfromfile batch processing separate directories
Post by: colacounty on December 05, 2021, 01:20:38 PM
hello World and thank you, Phil!
Newbie posting, using ExifTool for a couple of years for simple tasks now attempting to do something more advanced and stuck for almost an entire day.

My setup:
I keep large original JPGs in one folder and their smaller previews in another folder.
Filenames and extensions are very same.
Previews are made with a tool that discards all metadata, so I want to "-tagsfromfile" from original LARGE JPGs to small JPGs, matching by name.

Single file operatation works like a charm:
exiftool -tagsfromfile C:\LARGE\B0005929.jpg  C:\small\B0005929.jpg
1 image files updated


When attempting batch operation it is reporting false-positive success:
exiftool -r -tagsfromfile @ -srcfile C:\LARGE\%f.jpg  C:\small\
1 directories scanned
44 image files updated <<< my comment: in fact, no EXIF metadata is transfered

Tried different ways and different options but never managed to make it work in batch processing mode.
Windows10 64bit, elevated cmd, latest exiftool.exe, unsafe tags were removed before attempting batch.

Also, before attempting anything, all unsafe tags were removed in the following way over both folders:
exiftool -exif:all= -tagsfromfile @ -exif:all -thumbnailimage -unsafe *.jpg

Please let me know what am I doing wrong.
Thank you!
Title: Re: -tagsfromfile batch processing separate directories
Post by: StarGeek on December 05, 2021, 01:37:57 PM
Quote from: colacounty on December 05, 2021, 01:20:38 PM
When attempting batch operation it is reporting false-positive success:
exiftool -r -tagsfromfile @ -srcfile C:\LARGE\%f.jpg  C:\small\
1 directories scanned
44 image files updated <<< my comment: in fact, no EXIF metadata is transfered

Personally, I would use
exiftool -r -tagsfromfile @ -srcfile C:\LARGE\%f.jpg -All:All C:\small\

But otherwise, it is the correct command to copy the data.  Are you double checking with exiftool to compare the data between the two files or something else?  Can you provide a large and small image after running that command?
Title: Re: -tagsfromfile batch processing separate directories
Post by: colacounty on December 05, 2021, 02:28:01 PM
Quote from: StarGeek on December 05, 2021, 01:37:57 PM
Personally, I would use
exiftool -r -tagsfromfile @ -srcfile C:\LARGE\%f.jpg -All:All C:\small\

You are great, StartGeek! It worked!!!
Thank you!
Title: Re: -tagsfromfile batch processing separate directories
Post by: StarGeek on December 05, 2021, 03:04:19 PM
The differences is that when you don't include -All:All, it's the same as just using -All.  And using that will move tags to their preferred group locations rather than keeping them in the original group.  See first paragraph under the -TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT).  As an example, the Headline tag exists in both XMP and IPTC.  If -All:All isn't used, then XMP:Headline will get copied to the preferred location in IPTC, which is IPTC:Headline.
Title: Re: -tagsfromfile batch processing separate directories
Post by: colacounty on December 05, 2021, 03:07:51 PM
Yes, I've seen in in the userdoc and even tried to include at the time but it didn't work.


New update: and this is odd!

I've attempted to recreate success and flushed all Exif from small JPGs by using
exiftool -all= *.jpg

and then attempted to re-apply last succesfull command
exiftool -r -tagsfromfile @ -srcfile C:\LARGE\%f.jpg -All:All C:\small\

but this time around it gave me following output:
Warning: No writable tags set from C:/small/B0005925.jpg
Warning: No writable tags set from C:/small/B0005927.jpg
Warning: No writable tags set from C:/small/B0005928.jpg
Warning: No writable tags set from C:/small/B0005929.jpg
    1 directories scanned
    0 image files updated
   44 image files unchanged

These "from" above look a bit confusing to me because it sounds like a source vs. destination issue.
Very odd!

In the end, LARGE JPGs remain with Exit and small JPGs remaining without.
Title: Re: -tagsfromfile batch processing separate directories
Post by: StarGeek on December 05, 2021, 10:50:45 PM
Sorry, I should have paid more attention to what you wrote rather than copy/paste your commaand.

You have an @ sign after the -TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT).  This indicates that you want to copy tags from the file currently being processed back onto itself.  You then add the -srcfile option (https://exiftool.org/exiftool_pod.html#srcfile-FMT) to further complicate things.  Technically, it might work but it's better just to remove the @ -srcfile part in the first place.  Actually, thinking further, the @ might take precedence over the -srcfile argument.  See the third paragraph under the link for -srcfile.

Additionally, adding the -r (-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) will create further problems if there are subdirectories below C:\small\, as it will look for the files in those subdirectories only in C:\LARGE\.  Any subdirectories in C:\LARGE\ are ignored.

Your command should be
exiftool -tagsfromfile C:\LARGE\%f.jpg -All:All C:\small\

If you need to recurse into subdirectories below C:\small\, then you'll have to use the %d token with options to remove the top level directories.  See the Advanced features section of the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut).

Also, using wildcards such as *.jpg won't work with the -r (-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse).  See that link and Common Mistake #2c (https://exiftool.org/mistakes.html#M2).
Title: Re: -tagsfromfile batch processing separate directories
Post by: colacounty on December 06, 2021, 04:16:10 AM
Quote from: StarGeek on December 05, 2021, 10:50:45 PM
This indicates that you want to copy tags from the file currently being processed back onto itself. 

Thank you, StarGeek!
Very much appreciated!
Your last suggestion works for me now!!!