Author Topic: Using $filename in thumbnail path  (Read 182 times)


  • Newbie
  • *
  • Posts: 2
Using $filename in thumbnail path
« 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".
Code: [Select]
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.
Code: [Select]
exiftool "-ThumbnailImage<=thumbnails/aaa.jpg" "photos/aaa.jpg"

Any suggestions for what I'm doing wrong?



Windows 10


  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2569
Re: Using $filename in thumbnail path
« Reply #1 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, you'll see that it gives the %code variables for filename, directory, etc, and doesn't mention using tags at all. 

exiftool "-ThumbnailImage<=thumbnails/%F" "photos/*.jpg"
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.


  • Newbie
  • *
  • Posts: 2
Re: Using $filename in thumbnail path
« Reply #2 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).