using FileSequence in filename of extracted previews

Started by berliner_ffm, February 23, 2023, 01:50:31 PM

Previous topic - Next topic

berliner_ffm

I am trying to extract all previews from a bunch of files. Since I cannot always guarantee, that the original filenames are unique I wanted to use the FileSequence tag in the filename of the extracted previews. But somehow the tag is ignored.
This is my statement:
.\exiftool.exe D:\OneDrive\Pictures\_ImportTest\20220102-Christmas-Garden-Koblenz-02213*.ORF  -a -b -Preview:All -W "D:\%0f${FileSequence}-tmp-%t%c.jpg" -charset filename=UTF8

The exported previews are named "-tmp-PreviewImage.jpg", "-tmp-PreviewImage1.jpg", "-tmp-PreviewImage2.jpg" etc, instead of:
"0-tmp-PreviewImage.jpg", "1-tmp-PreviewImage.jpg", "2-tmp-PreviewImage.jpg"

The use of the "%c"-flag is only to prevent errors if two previews exist for the same tag (like 2 PreviewImage previews).

What am I missing regarding the use of FileSequence?

Thanks!

Phil Harvey

You can't use tag names in the argument of -W.

But luckily there is a "%nC" format code that gives you exactly what you want.  (The "n" starts counting from 1 instead of 0, but a "1" would have the same effect.)  See the -w option documentation for more details.

Also, your "%0f" code is unnecessary.

- 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

#2
Quote from: berliner_ffm on February 23, 2023, 01:50:31 PMThe use of the "%c"-flag is only to prevent errors if two previews exist for the same tag (like 2 PreviewImage previews).

The relevant part of the -w (-TextOut) option docs
     A special feature allows the copy number to be incremented for each processed file by using %C (upper case) instead of %c. This allows a sequential number to be added to output file names, even if the names are different.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

berliner_ffm

Hi Phil, hi StarGeek, thanks for the quick reply.
Unfortunately the %nc and also the %C flag will not really solve my issue. I wanted to have a clear file index from the sourcefile in the filename of the preview, e.g.

1-tmp-PreviewImage.jpg => the extracted preview from the previewImage tag of the 1st file.
1-tmp-PreviewImage2.jpg => extracted second preview from the previewImage tag (if two previews exist) of the 1st file.
2-tmp-PreviewImage.jpg => extracted preview from the previewImage tag of the 2nd file.

The %c and %nc flag is not working as a input file sequence number, if not all images contain all types of previews.

Also %C seems not to be the input file number if the number of previews per file differs.
Any other idea how to give the extracted previews any unique reference to the original file?

Phil Harvey

Quote from: berliner_ffm on February 23, 2023, 02:46:59 PM1-tmp-PreviewImage.jpg => the extracted preview from the previewImage tag of the 1st file.
1-tmp-PreviewImage2.jpg => extracted second preview from the previewImage tag (if two previews exist) of the 1st file.
2-tmp-PreviewImage.jpg => extracted preview from the previewImage tag of the 2nd file.

-W "%nC-tmp-%t%c.jpg" will do exactly this.

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

berliner_ffm

I tried this, but it is not giving me the correct names.
Lets assume 1 have 3 raw files with the following embedded previews:

1) File1.ORF
JpgFromRaw
ThumbnailTIFF
PreviewImage

2) File2.DNG
ThumbnailTIFF
PreviewImage

3) File3.ORF
JpgFromRaw
ThumbnailTIFF
PreviewImage (2 times)

Using the example command will result in the following preview files:

For File1.ORF:
1-tmp-JpgFromRaw.jpg
1-tmp-ThumbnailTIFF.jpg
1-tmp-PreviewImage.jpg
==>all fine!

For File2.DNG
2-tmp-ThumbnailTIFF.jpg
2-tmp-PreviewImage.jpg
==>all fine!

For File3.ORF
2-tmp-JpgFromRaw.jpg     ==>this is my problem since the index 2 is used because it is the second JpgFromRaw extracted but it belongs to the third file
3-tmp-ThumbnailTIFF.jpg
3-tmp-PreviewImage.jpg
3-tmp-PreviewImage2.jpg

Phil Harvey

What exact command did you use?

And what ExifTool version?
...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 ($).

berliner_ffm

#7
Hi Phil,

ok the situation seems a bit different when looking closer, because I could find the same behavior with only 1 file.
I put the test file here: Test image

the command used was:
.\exiftool.exe D:\File1.dng  -a -b -Preview:All -W "D:\%nC-tmp-%t%c.jpg" -charset filename=UTF8

the created files where:
1-tmp-JpgFromRaw.jpg
1-tmp-PreviewImage.jpg
1-tmp-ThumbnailImage.jpg
2-tmp-PreviewImage1.jpg

The problem is the last filename which should be 1-tmp-PreviewImage1.jpg

Phil Harvey

Ah, great!  I can reproduce your results.

I think this is a bug.  ExifTool is incrementing %C if there is a file name collision, but it shouldn't.  I'll fix this in the next release.

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

berliner_ffm