I have multiple scanned photos with a year in the filename. For example, a file may be named Tom_graduation_1952_photo.jpg or Mustang_Sally_1968.jpg. The year can appear anywhere within the name.
I have been trying without success to parse the four digits and insert that into the subject tag.
Can this be done and if so, how?
Appreciate any assistance.
Try
exiftool "-Subject+<${Filename;m/(\d{4})/;$_=$1}" /path/to/files/
This command will grab four consecutive numbers and add that to the XMP-dc:Subject, which is used to hold keywords.
Thank you. That works well.
Would it be possible to modify this to skip files that do not have a date in the name?
Try
exiftool -if "$filename=~m/(\d{4})/" "-Subject+<${Filename;m/(\d{4})/;$_=$1}" /path/to/files/
Thanks again. Works great!