News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Rename filename in accordance to tag: StackedImage value

Started by TravelPhoto, October 25, 2020, 06:11:11 PM

Previous topic - Next topic

TravelPhoto

Dear Phil, dear EXIFTOOL community,

I am looking for help. I am using a Olympus OM D E-M1 Mark III. This camera do have a camera internal image stacking function. It is possible to get a stacked image out of 15 images while pressing the shutter button once.
Unfortunately the camera do not add any information into the filename. I would prefer to have some information added to the filename.

I was able create a EXIFTOOL expression (in accordance to your documentation: https://exiftool.org/exiftool_pod.html#RENAMING-EXAMPLES) to add the whole value of the tag "StackedImage" to the filename, but the value is up to 25 digit long. This will blow up the total length of the filename and the path quite much.
exiftool -if  '$StackedImage ne "No" ' '-filename <%f_${StackedImage;}.%e' -ext jpg /myImageDirectory

I am looking for a solution to get the following filename structure:

"Original Filename" followed by "underscore" followed by "FS" followed by "underscore" followed by "number of stacked Images"".OriginalExtension"

Example from EXIF-data:
Tag: StackedImage  Value: Focus-stacked (8 images)

New filename should be: OriginalFilename_FS_8.JPG

or
Tag: StackedImage  Value: Focus-stacked (15 images)
15 is the maximum amount of images used for in-camera stacking.

New filename should be: OriginalFilename_FS_15.JPG

I've searched the Internet for a while, but not able to find a suitable solution. I'm guessing I had to use "SUBSTR" in a multiple way. Maybe I am just unable to understand the given examples.

Not mandatory but, I've found these small table in your documentation about tags from Olympus cameras. Is it possible to get these values as well into the filename? If yes, how to do?
0x0804   StackedImage   int32u[2]   '0 0' = No
'3 2' = ND2 (1EV)
'3 4' = ND4 (2EV)
'3 8' = ND8 (3EV)
'3 16' = ND16 (4EV)
'3 32' = ND32 (5EV)
'5 4' = HDR1
'6 4' = HDR2
'8 8' = Tripod high resolution
'11 16' = Hand-held high resolution
'1 *' = Live Composite (* images)
'4 *' = Live Time/Bulb (* images)
'9 *' = Focus-stacked (* images)


suggested Shortform for the longer values:
Tripod high resolution -> THR
Hand-held high resolution -> HHHR
Live Composite -> LC_Number of images
Live Time/Bulb -> LT_Number of images

Thanks a lot and best regards,

Bernard
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Greetings, Im not have images with $StackedValue so is hard to say. Maybe for the filename to try...
-if '$StackedValue =~ /stacked \(\d+ images\)$$/'  -TESTname'<%f_${StackedValue;s/.*\((\d+) images\)$/FS_$1/}.%e'

Im think its better to wait for the experts, because it seems like you want many conversions instead of just this one.
This can be useful with the custom tags, but Im not experiment making anything in the config file yet.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

Luuk2005

Sorry, Im not can do the custom tags yet. This the long way for testing on your command line..
-if '$StackedImage =~ /e/' -TESTname'<%f_${StackedImage;s/Tripod.*/THR/;s/Hand.*/HHHR/;s/.*Comp.*?(\d+).*/LC_$1/;s/.*Time.*?(\d+).*/LT_$1/;s/Focus.*?(\d+).*/FS_$1/}.%e'
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

TravelPhoto

#3
Hi Luuk2005, Thanks for your answer. Unfortunately the second mentioned command line always ended up with: "No file specified". I will adding some examples for different stacking modes.
While trying to uplaoad: Your attachment has failed security checks and cannot be uploaded. Please consult the forum administrator.
Will check tomorrow again.
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Its because I leave out Filespec/FolderName, because Im not sure what can be safe to match?
Try this, but please to see it conducts ALL jpegs in 'FolderName' if they have StackedImage like your explanations.
Please not to change the -TESTName until the experiments are over!

exiftool -ext jpg -if '$StackedImage =~ /e/' -TESTname'<%f_${StackedImage;s/Tripod.*/THR/;s/Hand.*/HHHR/;s/.*Comp.*?(\d+).*/LC_$1/;s/.*Time.*?(\d+).*/LT_$1/;s/Focus.*?(\d+).*/FS_$1/}.%e'  'YourFolderName'


Im not know what happens in security checks? Maybe to upload on another site and say the link, if its not to be illegal?
Im having many problems too, and must always use the proxy for exiftool.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

StarGeek

Quote from: TravelPhoto on October 26, 2020, 05:29:49 PM
While trying to uplaoad: Your attachment has failed security checks and cannot be uploaded. Please consult the forum administrator.
Will check tomorrow again.

Try zipping it.  It won't reduce the size, but might get around SMF's check.

Otherwise, something like a DropBox or Google Drive link.
* 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).

Luuk2005

Greeting again.. In case we never see the attachments, Im making template for ALL values except 'No'
exiftool -ext jpg -if '$StackedImage =~ /(?!No)../' -TESTname'<%f_${StackedImage;s/(.*) .*V\)$/$1/;s/Tr.*/THR/;s/Ha.*/HHHR/;s/.*Co.*?(\d+).*/LC_$1/;s/.*Bu.*?(\d+).*/LT_$1/;s/Fo.*?(\d+).*/FS_$1/}.%e' YourFolderName 

Please to modify if you like other conversions instead, because it makes them like...
StackedImage   _Suffix           StackedImage                            _Suffix
ND2 (1EV) ----> _ND2             Tripod high resolution ----------> _THR
ND4 (2EV) ----> _ND4             Hand-held high resolution -----> _HHHR
ND8 (3EV) ----> _ND8             Live Composite (3 images) ----> _LC_3
ND16 (4EV) --> _ND16            Live Time/Bulb (200 images) -> _LT_200
ND32 (5EV) --> _ND32            Focus-stacked (6 images) -----> _FS_6
HDR1 ----------> _HDR1
HDR2 ----------> _HDR2

If you already conducted renames, and now its problem to invent names like 'Name_FS_6_FS_6.jpg' use this instead..
exiftool -ext jpg -if '$StackedImage =~ /(?!No)../ and not $Filename =~ /_(ND\d[26]?|HDR[12]|(T|HH)HR|(L[CT]|FS)_\d{1,3})\.(?i)jpe?g$$/' -TESTname'<%f_${StackedImage;s/(.*) .*V\)$/$1/;s/Tr.*/THR/;s/Ha.*/HHHR/;s/.*Co.*?(\d+).*/LC_$1/;s/.*Bu.*?(\d+).*/LT_$1/;s/Fo.*?(\d+).*/FS_$1/}.%e' YourFolderName 

There might be better ways, but Im practicing now with the regex and sed.exe, and it seems to be very similiar.
Please not to change the -TESTName until the experiments are over!
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

TravelPhoto

Hi LUUK2005, absolut stunning! It is working. The problem yesterday was due the a wrong directory, I've used in the command line. Sorry for confusion :-(
The only problem left is with Live Comp and LiveTime. I will try to upload some files again.
Thanks a lot and best regards,
Bernard
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Please to update latest exiftool version!
But if now, you have many filenames like: 'Name_Unknown (# #)_Unknown (# #).jpg'  This to fix them first..
exiftool -Fast4 -ext jpg -TESTname'<${Filename; s/(?i)(\.jpe?g)$//; s/(.*?)(_Unknown \(\d+ \d+\))+$/$1/}%-c.%e' FolderName
It makes the output like...
'./Name001_Unknown (1 28).jpg' -----------------------------------------------------> './Name001.jpg'
'./Name001_Unknown (1 28).jpg_Unknown (1 28).jpg'  --------------------------> './Name001-1.jpg'   (incase of many)
'./Name002_Unknown (4 12).jpg_Unknown (4 12)_Unknown (4 12).jpg' -----> './Name002.jpg'

Please to say if you cant update, because then we can always add trailing s/// for non-supported values like..
s/Unknown \(1 (\d+)\)/LC_$1/;      (for LiveComposites)
s/Unknown \(4 (\d+)\)/LT_$1/;      (for Live Time/Bulbs)
etc

You can also fix names with unknown (# #) the same way, but Im thinking its easier to update instead.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

TravelPhoto

Dear Luuk2005,
many thanks for the new version of the excellent EXIFTOOL.
Now the "unknown" stacked Image values are gone and the proper values are displayed / updated. I've added the HDR1 and HDR2 values to the commend string:
exiftool -ext jpg -if '$StackedImage =~ /(?!No)../ and not $Filename =~ /_(ND\d[26]?|HDR[12]|(T|HH)HR|(L[CT]|FS)_\d{1,3})\.(?i)jpe?g$$/' -filename'<%f_${StackedImage;s/(.*) .*V\)$/$1/;s/HDR1.*/HDR1/;s/HDR2.*/HDR2/;s/Tr.*/THR/;s/Ha.*/HHHR/;s/.*Co.*?(\d+).*/LC_$1/;s/.*Bu.*?(\d+).*/LT_$1/;s/Fo.*?(\d+).*/FS_$1/}.%e'

Please find attached the images packed in a ZIP file.
Thanks again for your effort and time to create a solution for my request. Now I had to learn the whole syntax to be able to add some more tag data.

Best regards,
Bernd
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Im see you figure the s/match/replace.. Nice work! Its to be very helpful when exiftool's PrintConv is not fitting for the filenames, but if the exiftool already converts like you want, its not needed for s/// conversions, so its ok to remove s/HDR1.*/HDR1/;...... because the exiftool already makes it HDR1.

But if the exiftool PrntConv '5 4' --> 'HDR1 BadTextNotFittingForFilename' then its to be very helpful..  Its not any problem to help, this good learning experiment for me too because Im not know about StackedImage until I see this. Thanks much for the .zip, because Im adding many files to my test folder for the experiments.
Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

TravelPhoto

Thanks for your reply, but I am getting confused about your HDR... statement. Before I add the replacement command for HDR1 / HDR2 there was no change in the filename.
When I checked the EXIF data Exiftool -if  '$StackedImage ne "No" ' -stackedimage mydir the HDR information was displayed for the files.
But no need for more effort in this topic.

I will maybe come back in case I will receive a proper answer from the Olymus support about EXIF information about the "Starry Sky" option to get better images from night sky / stars and the focus differential amount use with the focus stacking funktion on my Olympus OM-D E-M1 Mark III

Thanks again for your assistance
Bernard
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Greeting again, and Sorry Im not the best with explanations.
Since the exiftool.exe already converts '5 4' --> HDR1, its just like you need (after the underscore).
So s/HDR1.*/HDR1/; is just converting HDR1 --> HDR1, so is not really needed.

This might be better explanation...
Any StackedImage values not s/// converted, would get _Suffixed to filename just like exiftool presents them.
So we just s/// convert the bad ones, and leave the good ones alone.

Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7

TravelPhoto

may ask you to update the command line in accordance the auto conversion.
Camera: Olympus OM-D E-M1 Mark III, Olympus OM-D E-M1X, Olympus OM-D E-M10 Mark II
EXIFTOOL Version: 12.47, MacBook Pro 13" MacOS: Monterey (12.6)

Luuk2005

Yours is already perfect, except that s/HDR1.*/HDR1/;s/HDR2.*/HDR2/; is not needed, so it can just be like..
exiftool -ext jpg -if '$StackedImage =~ /(?!No)../ and not $Filename =~ /_(ND\d[26]?|HDR[12]|(T|HH)HR|(L[CT]|FS)_\d{1,3})\.(?i)jpe?g$$/' -TESTname'<%f_${StackedImage;s/(.*) .*V\)$/$1/;s/Tr.*/THR/;s/Ha.*/HHHR/;s/.*Co.*?(\d+).*/LC_$1/;s/.*Bu.*?(\d+).*/LT_$1/;s/Fo.*?(\d+).*/FS_$1/}.%e'  'YourFolderName'

Sorry for the bad explanations.. The extra s/// dont hurt anything for this case, but its good to always practice with few s/// as possible.
This because each s/// can affect previous s/// conversions,  like if $Tag=ab123, then ${Tag;s/a/b/;s/b/c/}=cb123.
In this case, because you studied all the $StackedImage values, the extra HDR1/2 is not to be any problems.
You might even like to leave it in there, in case of changing your mind for conversions in the future!



Windows8.1-64bit, exiftool-v12.11(standalone), sed-v4.0.7