ExifTool Forum

ExifTool => Newbies => Topic started by: snorb on March 11, 2019, 04:16:03 PM

Title: Using $filename in thumbnail path
Post by: snorb on March 11, 2019, 04:16:03 PM
Hello all,

I'm trying to write thumbnails to a set of images and using the filename as part of the thumbnail path but I'm not having much joy.

I'm using a batch file on Windows, with the images in a subdirectory and the thumbnails also in a subdirectory. The thumbnails have the same name as the images.

The following fails with the error "Error opening file thumbnails/$filename".

exiftool "-ThumbnailImage<=thumbnails/$filename" "photos/*.jpg"


Testing with single image, and hardcoding the file names, as below, works OK, so it doesn't seem to a path issue.

exiftool "-ThumbnailImage<=thumbnails/aaa.jpg" "photos/aaa.jpg"


Any suggestions for what I'm doing wrong?

Thanks,

Stephen

Windows 10
ExifTool 11.2.9.0
Title: Re: Using $filename in thumbnail path
Post by: StarGeek on March 11, 2019, 04:25:05 PM
The answer lies in the error response.  Exiftool is trying to open thumbnails/$filename, not thumbnails/aaa.jpg.  That tells you that it's not reading $filename as a tag, but as static string.

If you read the docs for the -TAG<=DATFILE option (https://exiftool.org/exiftool_pod.html#TAG-DATFILE-or--TAG-FMT), you'll see that it gives the %code variables for filename, directory, etc, and doesn't mention using tags at all. 

Try
exiftool "-ThumbnailImage<=thumbnails/%F" "photos/*.jpg"
Title: Re: Using $filename in thumbnail path
Post by: snorb on March 11, 2019, 04:38:11 PM
I have to confess, I completely overlooked the -TAG<=DATFILE option.

It's working a treat (I just had to escape the %, as it's a Windows batch file).

Thanks.