I have successfully used the following command to copy the file names into the caption-abstract field:-
exiftool "-iptc:caption-abstract<filename" -r DIR
The filenames (and now captions) are of the form:-
F001 - Phototitle.jpg
Is there a command I can used to batch remove the 7 characters at the start and the 4 at the end, such that the caption that remains is:-
Phototitle
without the numbers or .jpg suffix?
Thank you
Try this
exiftool "-Caption-abstract<${Caption-abstract;s/^.{7}(.*)\.[^.]+$/$1/}" -r DIR
^.{7} matches the first seven characters
\.[^.]+$ matches characters from the last dot to the end of string, i.e. the extension of the filename. This is more flexible than just the last four characters and will work even if the filename ends in .jpeg or .tiff
(.*) captures everything else and copies it back into Caption-Abstract.
Thank you! That has worked perfectly!
David
Just as an alternative, this may be easier to understand:
exiftool "-Caption-abstract<${Caption-abstract;$_=substr($_,7,-4)}" -r DIR
- Phil
Thank you - yes that makes it easier for me to understand how to vary the number of characters removed.