I have two sets of images, one .tiff one .JPG, where the tiff ones are processed versions of the JPG.
There is a mismatch in the naming of the images. The .JPG ones start from 1, whereas the .tiff ones start from 21. Is is possible to rename the .tiff images so that they match?
Regards
Joel
Yes, but I need to know the exact format of the filename that you want changed. Is it simply "21.tiff" -> "1.tiff", etc...
If so, the command could be:
exiftool "-filename<${filename;my @a=split /\./;$a[0]-=20;$_=join '.',@a}" -ext tiff DIR
- Phil
Edit: It may be safest to add this to the command to be sure the files are processed in the correct order (otherwise some renames may fail): -fileorder filename
And first try this in a test directory to make sure it does what you want.
Thank you for the reply! I really appreciate it! Didn't realize (until now) that you had replied.
The format is IMG_Grey1.tiff -> R0010021.tiff, etc... That is, I would like to rename the IMG_Grey.tif to R0010021.tif.
So, apologies, I was not thinking clearly enough. The difference is not simply 20, but 10020.
If I understand your code correctly the following should go some way. I "just" need to discard the original name and append the R00 as well to each file.
exiftool "-filename<${filename;my @a=split /\./;$a[0]+=10020;$_=join '.',@a}" -ext tiff DIR
Thank you again! I would be very grateful for any further help.
Regards
Joel
The command Phil suggested, assumed the filename was just the number and that you just wanted a number as the new filename. Given you have additional characters in front and want an R in front and always have 7 digits, I suggest the following:
exiftool "-filename<${filename; my @a=split /\./; $a[0]=~s/^\D*//; $a[0]+=10020; $a[0]=sprintf('R%07d', $a[0]); $_=join '.',@a}" -ext tiff DIR
Cheers,
Hayo