ExifTool Forum

General => Metadata => Topic started by: neebah on July 30, 2017, 08:15:28 PM

Title: Renaming files with subsecs.
Post by: neebah on July 30, 2017, 08:15:28 PM
I would like to rename my files as follows
Year-Month-Day-HourMinuteSecond-SubSec
2017-07-30-123007-037

If no subseconds I would like to have ### instead. 

So far I have this for everything but the subseconds. 

-d %Y-%m-%d-%H%M%S-.%%e "-testname<DateTimeOriginal"

Title: Re: Renaming files with subsecs.
Post by: Phil Harvey on July 30, 2017, 09:10:23 PM
You want literally "###" ?

If so, this should do it:

exiftool -d %Y-%m-%d-%H%M%S- "-testname<${DateTimeOriginal}-###.%e"  "-testname<${DateTimeOriginal}${subsectimeoriginal;$_=substr($_.'000',0,3)}.%e" DIR

Some trickery was necessary to be sure SubSecTimeOriginal was 3 digits.

- Phil
Title: Re: Renaming files with subsecs.
Post by: neebah on July 30, 2017, 09:23:41 PM
Sorry yes I want ###.  That's what I use when the subseconds aren't known.  Is there a way to make it greater than or equal to 3 digits for the subsecs. 
Title: Re: Renaming files with subsecs.
Post by: Phil Harvey on July 31, 2017, 07:18:14 AM
For >= 3 digits you could do this:

"-testname<${DateTimeOriginal}${subsectimeoriginal;$_.='0'x(3-length)}.%e"

- Phil