Is there an easy way to do this - by renaming a set of photos to contain a sum of the two?
I know that width and height can be rather easily displayed in a renamed photo, but a summation (say 5 digit format) of these two values? Thanks.
Try
exiftool "-Filename<${Megapixels#;$_*=1000000}%f.%e" /path/to/files/
More details would be needed to limit it to five digits, as any image over 316x316 would exceed five digits.
If you really want the sum and not the product, you could do this:
exiftool "-testname<%f-${imagesize;tr/x/+/;$_=sprintf '%.5d',eval}.%e" DIR
If this gives you the names that you want, then replace "testname" with "filename" to do the actual renaming. With this, a 2688x2016 image named "phil.jpg" would be renamed to "phil-04704.jpg".
- Phil
Thanks Gents.
I have modified to fit Linux
exiftool '-testname<%f-${imagesize;tr/x/+/;$_=sprintf "%.5d",eval}.%e' .
Ok, now when I am done.
How to come to this result, where to study to understand it? Do I have to study Perl?
Cheers!
Quote from: Phil Harvey on October 19, 2020, 01:21:04 PM
If you really want the sum and not the product,
Ooops, I should read more closely.
Quote from: aniecki on October 19, 2020, 02:02:07 PM
How to come to this result, where to study to understand it? Do I have to study Perl?
The basics of file renaming are explained here (https://exiftool.org/filename.html). The advanced formatting feature is explained in the
-tagsfromfile section of the documentation, but the expressions (ie.
tr/x/+/;$_=sprintf "%.5d",eval) are pure Perl and require a knowledge of the language.
- Phil
Quote from: StarGeek on October 19, 2020, 02:11:41 PM
Ooops, I should read more closely.
...for once I'm the one that read things correctly. :P
- Phil
The product is also an interesting example here. Perhaps there is way to correct it slightly to change the format,
as given
'./CO-0282x0225-0005.jpg --> './63450CO-0282x0225-0005.jpg'
to (with leading zero)
'./CO-0282x0225-0005.jpg --> './063450CO-0282x0225-0005.jpg'
So even the low pixel photos will be prefixed with the same length string?
Thanks!
Just change %.5d to %.6d in the sprintf format string.
- Phil
For the sum, yes, yet the first example given was for product, so the problem with this command:
exiftool "-Filename<${Megapixels#;$_*=1000000}%f.%e" /path/to/files/
is that that here is not a format for the string.
282x225 eq 63450 is a 5 digit number, and we want it to be 6 digit (with leading zero).
Thanks.
exiftool "-Filename<${Megapixels#;$_=sprintf '%.6d', $_*1000000}%f.%e" /path/to/files/
- Phil
Thanks Phil, yes after giving me lead I even figured it out.