Batch rename xmp:title with incrementing numbers

Started by Urknecht, February 05, 2017, 10:31:49 AM

Previous topic - Next topic

Urknecht

Hi all!
I found this tool/forum while searching for a way to rename the XPTitle of all the images (jpeg) from a folder. I'm pretty new to this since I only renamed the image filenames with the IrfanView GUI and have no experience with this commandline tool.

I'm looking for a way to add incrementing numbers in front of the existing xmp:title, if there is one otherwise just write the number as xmp:title. I imagined there would be a way like the batch rename in IrfanView with pattern, which is only for filenames. I really would like to keep all the other metadata untouched, like creationdata and so on. So the result should look something like: 001_FirstTitle; 002_SecondTitle...
Is there any way I can achieve this with ExifTool?

Any help or advice would be greatly appreciated!

StarGeek

Do you want to use XPTitle or XMP:Title?  They're two different tags.

It's a little complicated, but try this.  Change Title to XPTitle if that's the tag you actually want.

exiftool "-Title<${FileSequence;$_=sprintf('%03d', $_+1 )}" "-Title<${FileSequence;$_=sprintf('%03d', $_+1 )}${Title;$_='_'.$_}" FileOrDir

This will throw a minor error Warning: [minor] Tag 'Title' not defined on files that don't have a Title tag, but that's ok, because that's when just the number gets written.  This starts numbering at 1.  If you want to continue counting upwards if you run the command on a new directory, change the +1 to the new starting number.

Example output
C:\>exiftool -title X:\!temp\aa
======== X:/!temp/aa/20130428132110-DSCN5071.JPG
Title                           : Test Title
======== X:/!temp/aa/2015-03-31_0043.JPG
======== X:/!temp/aa/BLYMP3001712172_01.JPG
Title                           : Test Title
    1 directories scanned
    3 image files read

C:\>exiftool "-title<${FileSequence;$_=sprintf('%03d', $_+1 )}" "-title<${FileSequence;$_=sprintf('%03d', $_+1 )}${Title;$_='_'.$_}" X:\!temp\aa
Warning: [minor] Tag 'Title' not defined - X:/!temp/aa/2015-03-31_0043.JPG
    1 directories scanned
    3 image files updated

C:\>exiftool -title X:\!temp\aa
======== X:/!temp/aa/20130428132110-DSCN5071.JPG
Title                           : 001_Test Title
======== X:/!temp/aa/2015-03-31_0043.JPG
Title                           : 002
======== X:/!temp/aa/BLYMP3001712172_01.JPG
Title                           : 003_Test Title
    1 directories scanned
    3 image files read
* 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).

Urknecht

Thank you so much for this! I really was afraid i had to do it manually, but this works exactly I imagined. It was indeed the Title not the XPTitle, thanks for the hint.
I'm so glad right now, thank you again so much!

StarGeek

* 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).