Author Topic: Want to split filename and copy into Title and Author/Creator fields  (Read 450 times)

AlanX

  • Jr. Member
  • **
  • Posts: 16
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3982
Re: Want to split filename and copy into Title and Author/Creator fields
« Reply #1 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 to apply a perl Regular Expression (RegEx) to split the filename into the appropriate strings.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

AlanX

  • Jr. Member
  • **
  • Posts: 16
Re: Want to split filename and copy into Title and Author/Creator fields
« Reply #2 on: December 05, 2018, 05:22:42 PM »
Wow, I know I could never have worked that out myself. Grateful thanks.