My files are named like
"2019_10_28_112702_IMG_2898.mp4"
. How can assign
"IMG_2898"
to xmp:UserComment?
Tried variations of
"-XMP-exif:UserComment<${FileName;s/\d{17}_(d{8})/$1/}"
but did not succeed :-)
Thank you for your help!
Will all the files have "IMG_(number)" as the data you're trying to pull or might there be something else.
Assuming the former, you could use
exiftool "-XMP:UserComment<${Filename;m/(img_\d+)/i;$_=$1}" /path/to/files/
This attempts to match and capture "img(underscore)(1 or more numbers)", case insensitively.
To break down what your original attempt actually did, the \d tried to match numbers only and the {17} required 17 of them. The underscores blocked that match. Assuming the second part was supposed to be \d{8}, that would have been the same except it was looking for 8 numbers.
All files ended with "IMG_(number)" and your proposed command worked good!
Thank you very much!