Hi,
I am trying to use the rename functionality to rename some files based on the value of the tag but the value of the tag sometimes has one or more trailing spaces or leading spaces in it.
I need to convert any spaces in the body of the tag value to underscore but I also want to get rid of any trailing or leading whitespace completely.
I understand I need to create a user-defined (composite) tag to do this but I don't have the knowledge of Perl substitution to know how to specify the expression I need to achieve this.
Can anyone help?
Many thanks,
Matthew.
Hi Matthew,
As of ExifTool 9.15 you can now do this with an advanced formatting expression. Specifically, this command should do what you want:
exiftool "-filename<${TAG;s/(^\s+|\s+$)//g;tr/ /_/}.%e" FILE
where TAG is your tag name, and FILE is one or more directory or file names. The above quoting is for Windows. Use single quotes instead if you are on Mac or Linux.
- Phil
Edit: Fixed a couple of slashes that should have been backslashes
That works great thanks!