Author Topic: Normalize a tag to only n characters  (Read 178 times)

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Normalize a tag to only n characters
« on: February 25, 2019, 11:12:55 PM »
Hello.

Please, how can I normalize a tag to just the first n characters? I want to do this to the SubSecTimeOriginal tag to get always 2 characters, because now I have photos from cameras who write only 1 character in this tag, other cameras who write 2 characters, and even cameras who write 3 characters.

How can be cut the 3 characters SubSecTimeOriginal tags to just 2? And how to increase the 1 characters SubSecTimeOriginal tags to 2 characters?

Thank you very much in advance.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14759
    • ExifTool Home Page
Re: Normalize a tag to only n characters
« Reply #1 on: February 26, 2019, 07:03:17 AM »
Using the advanced formatting feature:

${subsectimeoriginal;$_=substr($_.'0',0,2)}

But note that this will change "349" to "34".  It would be more difficult if you want values like this to round up.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

vicmarto

  • Jr. Member
  • **
  • Posts: 27
Re: Normalize a tag to only n characters
« Reply #2 on: February 26, 2019, 07:10:28 AM »
Wow! Impressive, thank you very much!!