by Luuk » Sun Feb 09, 2025 11:41 am
To suffix _WidthxHeightcm, Special(14) "Javascript" could use something like...
// Add rounded WidthxHeight in centimeters to image-files having a "Width" attribute
if (fileProperty('Width')) {
wide=Math.round(filePropertyNum('Width')/filePropertyNum('System.Image.HorizontalResolution')*2.54)
high=Math.round(filePropertyNum('Height')/filePropertyNum('System.Image.VerticalResolution')*2.54)
// Test image for bad _WidthxHeight at end, to replace with good _WidthxHeight
test = new RegExp("_" + wide + "x" + high + "cm" + "$" | "_" + wide + "x" + high + "$")
if (!name.match(test)) {
newName = name.replace(/^(.+)_\d+x\d+(cm)?$/, '$1') + "_" + wide + "x" + high + "cm"
}
}
If names already end with the correct _WidthxHeightcm (rounded), they wont get renamed.
If names end with the correct _WidthxHeight but without "cm", then only "cm" gets appended.
Any bad _WidthxHeightcm will get replaced with good-ones (in case someone edits the graphics)?
--------------------------------------------------------------------------------------------------------------------------------
If whole filenames can always be destroyed like the samples, use Numbering(10) with Mode==None, Pad==2
Then javascript could use something like...
if (fileProperty('Width')) {
wide=Math.round(filePropertyNum('Width')/filePropertyNum('System.Image.HorizontalResolution')*2.54)
high=Math.round(filePropertyNum('Height')/filePropertyNum('System.Image.VerticalResolution')*2.54)
newName = object("autonumber") + "_newName_" + wide + "x" + high + "cm"
}
If you have any non-image files, the Filters(12) "Condition" should have something like... fileProperty('Width')
Then to click the blue refresh-arrows, so that your numbering will only advance with true image files.