ExifTool Forum

ExifTool => Newbies => Topic started by: berebin on November 14, 2023, 10:37:43 AM

Title: [resolved] Rename files with specific OffsetTime format
Post by: berebin on November 14, 2023, 10:37:43 AM
Hey, everybody!

I am trying to rename photos using the pattern "YYYYYYMMDD_HHMMSS_gmtOFFSET.ext", where OFFSET is 4 characters (4 digits) for positive offset or 5 characters (minus sign and 4 digits) for negative offset. For example:


At the terminal on macOS, I do the following:

exiftool '-testname<${DateTimeOriginal}_gmt${OffsetTime}.%e' -d '%Y-%m-%d_%H-%M-%S%' .

As a result, I get the characters "plus" and "colon" in the offset part:


Is there an option to set a formatting pattern for the OffsetTime tag? Or perhaps there is another way to solve the problem?
Title: Re: Rename files with specific OffsetTime format
Post by: StarGeek on November 14, 2023, 10:47:40 AM
Try using
${OffsetTime;s/[+:]//g}

This will remove any + or : in the offset time tag.
Title: Re: Rename files with specific OffsetTime format
Post by: berebin on November 14, 2023, 10:53:58 AM
Quote from: StarGeek on November 14, 2023, 10:47:40 AMTry using
${OffsetTime;s/[+:]//g}

This will remove any + or : in the offset time tag.
StarGeek, you made my evening! Thank you for the quick reply.
Title: Re: [resolved] Rename files with specific OffsetTime format
Post by: Phil Harvey on November 14, 2023, 12:31:46 PM
Just a very minor point, but using tr/// (translate) instead of s/// (substitute) is a more efficient way to remove characters:

${OffsetTime;tr/+://d}

- Phil
Title: Re: [resolved] Rename files with specific OffsetTime format
Post by: berebin on November 17, 2023, 11:10:12 AM
Quote from: Phil Harvey on November 14, 2023, 12:31:46 PMJust a very minor point, but using tr/// (translate) instead of s/// (substitute) is a more efficient way to remove characters:

${OffsetTime;tr/+://d}

- Phil

Phil, thank you for your reply as well!