How do I set a thumbnail image into similar-named files?

Started by dwlott, January 31, 2024, 10:57:19 AM

Previous topic - Next topic

dwlott

Hello again,
How do I set a thumbnail image into similar-named files in a different folder? 

For example, I want File01_thumb.jpg to be the ThumbnailImage for its like-named file in the target folder, minus the "_thumb" part of the source file name.  The following code is missing parse for the "_thumb" and might have other problems. 

-ThumbnailImage<=
E:\mySourceFolder\extract\File01_thumb.jpg
-srcfile
e:\myTargetFolder\%f.%e


I also want to know how to set a thumbnail image into like-named files in the same folder.

I know this code has problems, but I'm including it to help illustrate what I'm trying to do and that I'm using an args file.

-ThumbnailImage<=
E:\mySourceFolder\extract\File01_thumb.jpg
-srcfile

Thanks for your help, as always.



StarGeek

I'm a bit confused about what directory you are processing, but I think I can give some examples

This will embed the thumbnails from "mySourceFolder" into the files in "myTargetFolder"
exiftool "-ThumbnailImage<=E:\mySourceFolder\extract\%f_thumb.jpg" e:\myTargetFolder\

In this case, it takes the base filename in "myTargetFolder", appends "_thumb", and looks for the thumb in "mySourceFolder"

Using the -srcfile option.  At least I think it will work.  IMO, you are introducing unneeded complexity with the use of -srcfile.
exiftool "-ThumbnailImage<=E:\mySourceFolder\extract\%f.%e" -srcfile e:\myTargetFolder\%-.6f.%e E:\mySourceFolder\extract\

Here I'm taking the name of the thumb in "mySourceFolder", removing the last six characters of the base filename, i.e. removing "_thumb", and looking in "myTargetFolder" for the file to embed i.e. the srcfile.  Then back to the original name for the <=.

Though
"-ThumbnailImage<=E:\mySourceFolder\extract\%f.%e"
probably should be replaced by
"-ThumbnailImage<=%d%f.%e"
* 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).

dwlott

-ThumbnailImage<=
E:\mySourceFolder\extract\%f_thumb.jpg
E:\myTargetFolder\

As you suggested, StarGeek, I found the above best for my needs in setting ThumbnailImage into similar-named files in a different folder.

With that knowledge, I found that the following code works for write the folder of images to the ThumbnailImage of files of a different extension. Note that the .orf extension is specified in the command. 

-PreviewImage<=E:\mySourceFolder\extract\%f_thumb.jpg
e:\myTargetFolder\*.orf

Now, I want to include like-named subfolders.  I have a tree of thumbnails that I want to set into an identical tree of images, the file names similar, as we have been working on in this thread.

I am trying this string %:3d in the destination line as shown in this code:

-r
-PreviewImage<=E:\mySourceFolder\extract\%f_thumb.jpg
e:\myTargetFolder\%:3d*.orf

exiftool replies "No matching files"

Thank you again for your help.

 

Phil Harvey

Quote from: dwlott on February 07, 2024, 01:51:02 PM-r
-PreviewImage<=E:\mySourceFolder\extract\%f_thumb.jpg
e:\myTargetFolder\%:3d*.orf

exiftool replies "No matching files"

You can't use % codes in the target file name.  I don't understand what you are trying to do.  Can you give examples of a few target file names the the corresponding thumbnail names?

- 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 ($).

StarGeek

Quote from: dwlott on February 07, 2024, 01:51:02 PMWith that knowledge, I found that the following code works for write the folder of images to the ThumbnailImage of files of a different extension. Note that the .orf extension is specified in the command. 

-PreviewImage<=E:\mySourceFolder\extract\%f_thumb.jpg
e:\myTargetFolder\*.orf

Now, I want to include like-named subfolders.

You can't use a wildcard and recurse into subdirectories.  You need to use the -ext (-extension) option to limit the types of files to process.

See Common Mistake #2 and the -r (-recurse) option.

The files that are in e:\myTargetFolder\ are the base file paths.  What you want to do is take that base path, edit it using %d so that it matches the locations in E:\mySourceFolder\extract\.

What I think you want is
-PreviewImage<=E:\mySourceFolder\extract\%:2d%f_thumb.jpg

This takes the directory path of the ORF file, removes the top two directories, in this case e:\myTargetFolder\ and append what remains after E:\mySourceFolder\extract\.

For example, you have two files
e:\myTargetFolder\File_1.orf
e:\myTargetFolder\SubDir\SubFile_1.orf

Using %:2d would remove e:\myTargetFolder from both of these filepaths, leaving File_1.orf with no directory path included and SubFile_1.orf with a SubDir\.

These directory paths are then appended to E:\mySourceFolder\extract\ giving you
E:\mySourceFolder\extract\
E:\mySourceFolder\extract\SubDir\

Then the %f base filename is added
E:\mySourceFolder\extract\File_1
E:\mySourceFolder\extract\SubDir\SubFile_1

And then finally _thumb.jpg appended, telling exiftool to look for these file to embed in the original ORF files
E:\mySourceFolder\extract\File_1_thumb.jpg
E:\mySourceFolder\extract\SubDir\SubFile_1_thumb.jpg
* 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).

dwlott

Thank you, guys; I am learning from what you wrote, but please help me further in reading and writing binaries to and from like-named files. 

I aim to extract thumbnails to a thumbnail folder, keeping the directory structure, and with another command, write them back from where they came.

For clarity, I am working in different folders now as shown in the screenshots below.

When I run the following command to extract thumbnails, the thumbnails are saved correctly and structured in the destination folders, but Exiftool returns error messages.  I want to use the best command to avoid the error messages.  Also, please help me with the command for writing the thumbnails back to their original files.

-r
-JpgFromRaw
-ThumbnailImage
E:\images
-a
-b
-W
E:\thumbs\%:2d%f.%s

ExifTool reply:
QuoteOutput file E:/thumbs/File01_thumb.jpg already exists for E:/images/File01.ORF
Output file E:/thumbs/File02_thumb.jpg already exists for E:/images/File02.ORF
Output file E:/thumbs/File03_thumb.jpg already exists for E:/images/File03.ORF
Output file E:/thumbs/File04_thumb.jpg already exists for E:/images/File04.ORF
    2 directories scanned
    1 directories created
    9 image files read
    4 files could not be read
    9 output files created

The thumbs folder is known empty when I run the command. I've been experimenting for a few hours.

Here is a screenshot of the images folder.


Here is a screenshot of the images sub folder.


Here is a screenshot of the thumbnail folder.


Here is a screenshot of the thumbnail sub folder.



Phil Harvey

Your command is writing both JpgFromRaw and ThumbnailImage to the same file name, which is why you only get one, and why you get an error message for the other.  The best way to separate them is to add %t (the tag name) to the output file name, like this to add the tag name to the file name:

-W
E:/thumbs/%:2d%f_%t.%s

or like this to put them in a separate directory:

-W
E:/thumbs/%:2d%t/%f.%s

- 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 ($).

dwlott

Thank you, Phil,
I adjusted the command by removing the 2nd tag and using the %t option.  The thumbnails are produced, but there are error messages in the ExifTool reply.  See below the command I am trying, the ExifTool reply, and the thumbnail files produced.

-r
-ThumbnailImage
E:\images
-a
-b
-W
E:\thumbs\%:2d%f_%t.%s

QuoteOutput file E:/thumbs/File01_ThumbnailImage.jpg already exists for E:/images/File01.ORF
Output file E:/thumbs/File02_ThumbnailImage.jpg already exists for E:/images/File02.ORF
Output file E:/thumbs/File03_ThumbnailImage.jpg already exists for E:/images/File03.ORF
Output file E:/thumbs/File04_ThumbnailImage.jpg already exists for E:/images/File04.ORF
    2 directories scanned
    1 directories created
    9 image files read
    4 files could not be read
    9 output files created


StarGeek

There are probably multiple ThumbnailImage in the file.  Add a copy number %c to the thumb filename.
* 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).

dwlott

Please help further with a command that will set a tree of thumbnails into an identical tree of images. 
e:\thumbs
   has files like: file01_ThumbnailImage.jpg, file02_ThumbnailImage.jpg
   (with subfolders)
e:\images
   has files like: file01.jpg, file02.jpg
   (with subfolders)


StarGeek

Just add the text to the proper place in the format string. For example, above I suggested
%:2d%f_thumb.jpg
instead of "_thumb", you would use "_ThumbnailImage"
%:2d%f_ThumbnailImage.jpg
* 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).

dwlott

I think that I am getting closer.  Please help me include the subfolders.
This command updates the files in e:\images, but not the files in e:\images\subs
-r
-ThumbnailImage<=E:\thumbs\%:2d%f_ThumbnailImage.jpg
E:\images\*.orf

ExifTool reply:
Quote4 image files updated

Phil Harvey

This is Common Mistake 2c, which StarGeek already mentioned in his post above.

Try this:

-r
-ThumbnailImage<=E:\thumbs\%:2d%f_ThumbnailImage.jpg
-ext
orf
E:\images

- 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 ($).

dwlott