ExifTool Forum

ExifTool => Newbies => Topic started by: AlanX on December 05, 2018, 02:31:07 PM

Title: Want to split filename and copy into Title and Author/Creator fields
Post by: AlanX on December 05, 2018, 02:31:07 PM
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.
Title: Re: Want to split filename and copy into Title and Author/Creator fields
Post by: StarGeek on December 05, 2018, 02:41:08 PM
Try
exiftool "-Title<${Filename;s/_.*//}" "-Creator<${Filename;s/.*?_(.*)\.[^.]+/$1/;}" FileOrDir

This command uses the Advanced formatting feature (https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature) to apply a perl Regular Expression (RegEx) to split the filename into the appropriate strings.
Title: Re: Want to split filename and copy into Title and Author/Creator fields
Post by: AlanX on December 05, 2018, 05:22:42 PM
Wow, I know I could never have worked that out myself. Grateful thanks.