ExifTool Forum

ExifTool => Newbies => Topic started by: stanje1 on October 26, 2022, 09:46:56 AM

Title: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: stanje1 on October 26, 2022, 09:46:56 AM
I have set of jpgs in one directory, with sub-directories, with some tags set, I have a second directory with exact same file names and sub-directories with those tags not populated (diff resolution pics).  I would like to copy the selected tags from all the files in source directory structure to the equivalent files in second directory.   I am on Win 11, EXIFTOOL cmd line ver. 12.4.9.0.

Dir1/Sub1(multiple subs)/File1xx.jpg etc
Dir2/Sub1(multiple subs)/File1xx.jpg etc

Closest I come is the following but I cannot get it to go to the output files... syntax for output directory wrong?  It duplicates/appends the input source directory in beginning of the output string?

exiftool -tagsfromfile inexif/%d%f.jpg -ImageDescription -Caption-Abstract -Description -r outexif

Errors...
Warning: Error opening file - inexif/outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_040.jpg
Warning: Error opening file - inexif/outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_041.jpg
.....
Warning: Error opening file - inexif/outexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_037.jpg
Warning: Error opening file - inexif/outexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_038.jpg
.....
    4 directories scanned
    0 image files updated
  105 image files unchanged

Sorry if I could not find this answer anywhere !
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: StarGeek on October 26, 2022, 12:16:31 PM
You need to edit the %d variable.  The value of that is always the directory for the file that is being processed.  Since the files is in the "outexif" directory, that will be part of the %d variable.

The docs for editing the %d variable are listed under the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) under Advanced features.  I think you want to use %:1d, which removes the top level directory.  So using inexif/%:1d will keep the directory structure below "outexif" and look for the source files with that directory path in the "inexif" directory.
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: stanje1 on October 26, 2022, 07:11:44 PM
ok.. still a problem with syntax, but read the advanced -w (-TextOut) and figuired it out, see below...

First tried:
exiftool -tagsfromfile inexif/%:1d -ImageDescription -Caption-Abstract -Description -r outexif
and got these errors... is it not going down to within the subfolders...
The inexif jpg files do have the target metadata fields populated

>>>>>>>
C:\Users\joest\Desktop>exiftool -tagsfromfile inexif/%:1d -ImageDescription -Caption-Abstract -Description -r outexif

Warning: No writable tags set from inexif/Album_2010/D10012_Flowers_Mar19/
Warning: No writable tags set from inexif/Album_2010/D10012_Flowers_Mar19/
Warning: No writable tags set from inexif/Album_2010/D10012_Flowers_Mar19/
.......
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/
    4 directories scanned
    0 image files updated
  105 image files unchanged
>>>>>>

After reading notes and looking at it, decided I simply need to re-add the file level and extension.... got some different errors on some of the file contents(?) and some legitimate no tag data files, but seems to work.  I did expect maybe _original files, but it actually overwrote the output files, which is fine.

This worked... thank you !!!

>>>>>>>
C:\Users\joest\Desktop>exiftool -tagsfromfile inexif/%:1d%f.jpg -ImageDescription -Caption-Abstract -Description -r outexif
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_001.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_003.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_026.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_027.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_029.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_031.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_032.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_033.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_035.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_036.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_057.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10012_Flowers_Mar19/D10012_Flowers_Mar19_058.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_008.JPG
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_012.JPG
Warning: Error opening file - inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_022.jpg
Warning: [minor] Adjusted MakerNotes base by 70 - outexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_024.JPG
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_035.jpg
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_036.jpg
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_037.jpg
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_038.jpg
Warning: No writable tags set from inexif/Album_2010/D10015_Flowers_Mar26/D10015_Flowers_Mar26_039.jpg
    4 directories scanned
   99 image files updated
    6 image files unchanged
>>>>>>>
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: Phil Harvey on October 26, 2022, 08:29:01 PM
Quote from: stanje1 on October 26, 2022, 07:11:44 PMI did expect maybe _original files, but it actually overwrote the output files, which is fine.

ExifTool won't overwrite the original files unless you specify -overwrite_original or -overwrite_original_in_place.

Something else must be going on here.

- Phil
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: stanje1 on November 01, 2022, 09:45:17 AM
Sorry.. it did save / create the _originals.
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: stanje1 on November 01, 2022, 11:38:45 AM
okay.. I still do not get directory commands for this recursive tagsfromfile.  My simple example / test with two folders at the same level works, but now I am trying on real files and I cannot figure how to get it to different structures.  I have tried various starting levels of directories and various %:1d, %:3d or %1:2d etc etc.   The best I can do is CD to the working starting directory and then specify an absolute output path... but it still appends the input last directory to the string.  I am still missing something on this syntax?

My structure:
Input Folders:  D:Archive-Pictures/Albums/Album_2010-2018/Album_2010/subfolder1, subfolder2, subfolder3 etc etc
Output Folders: D:Archive-Pictures/Tif_Archive_2005-2010/Tif_Archive_2010/subfolder1, subfolder2, subfolder3 etc etc

Last try:
cmd /k
D:
cd Archive-Pictures/Albums/Album_2010-2018
exiftool -tagsfromfile Album_2010/%:1d%f.jpg -ImageDescription -Caption-Abstract -Description -r D:/Archive-Pictures/Tif_Archive_2005-2010/Tif_Archive_2010

I get, for example:
Warning: Error opening file - Album_2010/Archive-Pictures/Tif_Archive_2005-2010/Tif_Archive_2010/D10059_July4th/D10059_July4th_008.jpg

What am I missing?
Thanks from a Newbie !

Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: StarGeek on November 01, 2022, 12:03:40 PM
Remember that the %d variable is the directory of the file that is being edited. So the file being edited according to your error would be
D:/Archive-Pictures/Tif_Archive_2005-2010/Tif_Archive_2010/D10059_July4th/D10059_July4th_008.tif

So that means you need to remove the top 4 directory levels so you only have subdirectories below Tif_Archive_2010.  That would be %:4d

Then, you have to make sure to replace those top 4 levels with the path to the source files.  In this case, D:/Archive-Pictures/Albums/Album_2010-2018/Album_2010/.  This would give
-tagsfromfile D:/Archive-Pictures/Albums/Album_2010-2018/Album_2010/%:4d%f.jpg

Note, I don't have time to completely test this, but I think this is what you want.
Title: Re: Copy tags fm files fm dir1 to same name files in dir2 -r
Post by: stanje1 on November 01, 2022, 01:56:42 PM
Thank you !!
Worked. 
Used this, as you said:
cmd /k
D:
exiftool -tagsfromfile D:/Archive-Pictures/Albums/Album_2010-2018/Album_2010/%:4d%f.jpg -ImageDescription -Caption-Abstract -Description -r D:/Archive-Pictures/Tif_Archive_2005-2010/Tif_Archive_2010

Got this (net, less files without the tags set that were specified):
  116 directories scanned
 2224 image files updated
 5595 image files unchanged

Thank you, thank you !
Now, off to do 10 years worth !