Batch set image-specific metadata from text file for images in separate folders

Started by ErinF, January 05, 2020, 11:55:54 PM

Previous topic - Next topic

ErinF

I have been creating text files to batch set image-specific metadata for large sets of files stored in a common directory. I would like to apply this same method to images that are not stored in a common directory. In this case, my specific goal is find each image in a list, edit tags as instructed, and place the updated copy in a common folder. The following command line accomplishes this when I know the full path to the source image:

exiftool -SpecialInstructions=XYZ -o "C:\Folder1\NewFolder\MyFile.JPG" "C:\Folder1\Folder2\Folder3\MyImage.JPG"

I have not been able to figure out how to accomplish this when I don't know the full path to the source file, but perhaps just the upper level directory it is stored within.

Is there a way to do this?

Help is much appreciated!


Phil Harvey

You could do this:

exiftool -SpecialInstructions=XYZ -o "C:\Folder1\NewFolder\%f.%e" -r -if "$filename eq 'MyImage.JPG'" -fast4 "C:\Folder1"

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ErinF

Thanks very much for the prompt reply to my question. I've had a chance to try this suggestion, and I think it is very nearly the solution. However, I get different results depending on how I run the command.

If I run the following line by entering it directly at the command prompt:

exiftool -k -SpecialInstructions=ML -o "C:\DigitalCatalogs\Bp\MachineLearning\%f.%e" -r -if "$filename eq '20180403-M28-0300.JPG'" -fast4 "C:\DigitalCatalogs\Bp\Annual Archives"

I get the following return:

Error: 'C:/DigitalCatalogs/Bp/MachineLearning/20180403-M28-0300.JPG' already exists - C:/DigitalCatalogs/Bp/Annual Archives/2018/[Originals]/20180403-M28-0300.JPG
   36 directories scanned
8139 files failed condition
    1 image files created
    0 image files updated
    1 files weren't updated due to errors


But the file is successfully found, and a new copy is created in the specified folder with the tag updated- so it appears to work fine in this context, despite the error.

However, if I have the exact same line in a .bat file, and attempt to run it by double-clicking the file from wherever it is stored (the way I typically use Exiftool for setting unique values to large numbers of files), I see the following in the console when it opens (with the command line and response):

C:\DigitalCatalogs\Bp\annual archives>exiftool -k -SpecialInstructions=ML -o "C:\DigitalCatalogs\Bp\MachineLearning\e" -r -if "$filename eq '20180403-M28-0300.JPG'" -fast4 "C:\DigitalCatalogs\Bp\Annual Archives"
Error: 'C:/DigitalCatalogs/Bp/MachineLearning/e' already exists - C:/DigitalCatalogs/Bp/Annual Archives/2018/[Originals]/20180403-M28-0300.JPG
   36 directories scanned
8139 files failed condition
    1 image files created
    0 image files updated
    1 files weren't updated due to errors


In this case, an empty file called "e" with no extension is created in the specified folder. Looking at the command line in the console itself, it appears that the %f and %e elements are not translated correctly from the command line in the batch file.

Do you have any suggestions for why this might be occurring and how to correct it?

Thanks again! Like so many have said, this tool is phenomenal and it makes my job so much easier in so many ways.

StarGeek

Quote from: ErinF on January 13, 2020, 04:38:20 PM
But the file is successfully found, and a new copy is created in the specified folder with the tag updated- so it appears to work fine in this context, despite the error.

You can use %c to indicate a copy number for when there is a filename collision.  For example, %f%-c.%e.  See the -w (textout) option for details.

QuoteHowever, if I have the exact same line in a .bat file,

See FAQ #27 (or my .sig).
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

ErinF

Thank you StarGeek! I see I am not the first newbie who was foiled by Windows... the extra % was, of course, the issue.