ExifTool Forum

ExifTool => Newbies => Topic started by: vicmarto on February 25, 2019, 11:12:55 PM

Title: Normalize a tag to only n characters
Post by: vicmarto 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.
Title: Re: Normalize a tag to only n characters
Post by: Phil Harvey 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
Title: Re: Normalize a tag to only n characters
Post by: vicmarto on February 26, 2019, 07:10:28 AM
Wow! Impressive, thank you very much!!