ExifTool Forum

ExifTool => Newbies => Topic started by: berliner_ffm on February 23, 2023, 01:50:31 PM

Title: using FileSequence in filename of extracted previews
Post by: berliner_ffm on February 23, 2023, 01:50:31 PM
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!
Title: Re: using FileSequence in filename of extracted previews
Post by: Phil Harvey on February 23, 2023, 02:03:35 PM
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
Title: Re: using FileSequence in filename of extracted previews
Post by: StarGeek on February 23, 2023, 02:11:10 PM
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 (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) 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.
Title: Re: using FileSequence in filename of extracted previews
Post by: berliner_ffm on February 23, 2023, 02:46:59 PM
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?
Title: Re: using FileSequence in filename of extracted previews
Post by: Phil Harvey on February 23, 2023, 02:50:43 PM
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
Title: Re: using FileSequence in filename of extracted previews
Post by: berliner_ffm on February 23, 2023, 03:00:21 PM
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
Title: Re: using FileSequence in filename of extracted previews
Post by: Phil Harvey on February 23, 2023, 03:05:07 PM
What exact command did you use?

And what ExifTool version?
Title: Re: using FileSequence in filename of extracted previews
Post by: berliner_ffm on February 23, 2023, 03:21:12 PM
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 (https://u.pcloud.link/publink/show?code=XZxzcgVZHkuH84g13X7X2aEuQzgSm4dkXa57)

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
Title: Re: using FileSequence in filename of extracted previews
Post by: Phil Harvey on February 23, 2023, 03:32:59 PM
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
Title: Re: using FileSequence in filename of extracted previews
Post by: berliner_ffm on February 23, 2023, 03:35:20 PM
That's great. Thanks a lot for your help!