Help with EXIFTOOL and JavaScript
Hi there,
I'm new to Advanced Renamer and I'm looking for a method to rename photo files based on some exif tags.
Eg. the fujifilm Tag "AutoBracketing" and "SequenceNumber".
I'm used to exiftool, but new to JavaScript and the combination with Advanced Renamer.
Can somebody help me with a simple example for a script to substitute parts of the filename regarding a combination of both tags? That would help me to get started easier.
Perhaps: If the Tag "AutoBracketing" is "on" and SequenceNumber is "2", than replace a part of the filename with "-BKT" & SequenceNumber.
Thank's for help
Ulrich
I'm new to Advanced Renamer and I'm looking for a method to rename photo files based on some exif tags.
Eg. the fujifilm Tag "AutoBracketing" and "SequenceNumber".
I'm used to exiftool, but new to JavaScript and the combination with Advanced Renamer.
Can somebody help me with a simple example for a script to substitute parts of the filename regarding a combination of both tags? That would help me to get started easier.
Perhaps: If the Tag "AutoBracketing" is "on" and SequenceNumber is "2", than replace a part of the filename with "-BKT" & SequenceNumber.
Thank's for help
Ulrich
Reply to #1:
Welcome Ulrich!
This code should get you started:
1) Create a new script method ( https://www.advancedrenamer.com/user_guide/v4/method_script ).
2) Paste this next code in the "function(index, item)" block and apply it:
//-------------------------------------------------------
// "function( index, item)" script
//-------------------------------------------------------
let bracketing = app.parseTags("<ExifTool:AutoBracketing>");
if (/^on$/i.test (bracketing) ) { // Is the whole value "On"? case-insensitive
let seqNum = app.parseTags("<ExifTool:SequenceNumber>");
return item.newBasename + "-BKT " + seqNum; // append to the filename
}
//-------------------------------------------------------
For now it adds "-BKT {sequence Number}" to the end of the filename.
If AutoBracketing is not "On, or is missing, the filename will be unchanged.
Regards,
Randy
Welcome Ulrich!
This code should get you started:
1) Create a new script method ( https://www.advancedrenamer.com/user_guide/v4/method_script ).
2) Paste this next code in the "function(index, item)" block and apply it:
//-------------------------------------------------------
// "function( index, item)" script
//-------------------------------------------------------
let bracketing = app.parseTags("<ExifTool:AutoBracketing>");
if (/^on$/i.test (bracketing) ) { // Is the whole value "On"? case-insensitive
let seqNum = app.parseTags("<ExifTool:SequenceNumber>");
return item.newBasename + "-BKT " + seqNum; // append to the filename
}
//-------------------------------------------------------
For now it adds "-BKT {sequence Number}" to the end of the filename.
If AutoBracketing is not "On, or is missing, the filename will be unchanged.
Regards,
Randy