Want to split filename and copy into Title and Author/Creator fields

Started by AlanX, December 05, 2018, 02:31:07 PM

Previous topic - Next topic

AlanX

I have competition images which have names like Another Beautiful Sunset_Joe Bloggs.jpg. That is Title[underscore]Author's name.
What I need to do is take the text before the underscore, and copy that bit to the Title field, and take the text after the underscore, and copy that bit (without the file extension) to the Author/Creator field.
I've done this sort of thing 50 years ago with recursive subs in Basic (!), but have no idea where to start looking to do this in ExifTool. Any help greatly appreciated.

StarGeek

Try
exiftool "-Title<${Filename;s/_.*//}" "-Creator<${Filename;s/.*?_(.*)\.[^.]+/$1/;}" FileOrDir

This command uses the Advanced formatting feature to apply a perl Regular Expression (RegEx) to split the filename into the appropriate strings.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

AlanX

Wow, I know I could never have worked that out myself. Grateful thanks.