How do I use milliseconds when renaming files?

Started by brenton, July 14, 2010, 11:36:44 AM

Previous topic - Next topic

Phil Harvey

Hi Uwe,

Leading zeros are significant in SubSecTimeOriginal.  ("01" is 0.01 sec, while "001" is 0.001 sec.)  So you change the value if you pad with leading zeros.

You should pad with trailing zeros as in my post. ("010" is still 0.01 sec.)

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

Uwe

#16
Hi Phil,
thanks for your very fast respond.
These are the tags in the photos:
Sub Sec Time Digitized           8
Sub Sec Time Digitized           01
Sub Sec Time Digitized           14
Sub Sec Time Digitized           31
Sub Sec Time Digitized           64
After the rename I get these files and this sort(depending on ascending or descending):
20160115_170512-800.dng
20160115_172612-010.dng
20160115_172612-140.dng
20160115_172612-310.dng
20160115_172612-640.dng
My problem are the values "8" and "01" written by the camera. Following your explanation: 8=0,8s, 01=0,01, ...64=0,64s. In this case the problem is the sort of the Windows file system and other applications.
Regards, Uwe

Phil Harvey

Hi Uwe,

The sort order looks fine to me (the minutes are different for the "800" file).

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

Uwe

Hi Phil,
sorry, I was so focussed on the ms that I didn't see the wood for the trees.
Regards, Uwe

Juana

Hi,

Sorry to dig out this old topic, but I just can't make this function work.

exiftool -d %Y-%m-%d-%H-%M-%S%%c.%%e "-filename<datetimeoriginal" DIR
works fine and brings out this result: 2017-07-08-14-46-08.RW2

So, how do I add this string: ${subsectimeoriginal;$_.=0 x(3-length)} to get the format:
2017-07-08-14-46-08-000.RW2 ?

Thanx in advance

Phil Harvey

Try this:

exiftool -d %Y-%m-%d-%H-%M-%S "-filename<${datetimeoriginal}-${subsectimeoriginal;$_.=0 x(3-length)}%-c.%e" DIR

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

RPSM

Apologies for the old thread, but is it possible to pad with zeros in front of the tag? Specifically, for example, for episode numbers to show as 01, 02, 03, 04, etc.?

Hayo Baan

Yes, that's actually what Phil's last command does. But if you show us what you are now using as rename string and where you'd like to see the leading zeros, we could give you the exact command to use.
Hayo Baan – Photography
Web: www.hayobaan.nl

RPSM

This may seem dumb, but once it clicked it was "just Perl", I got it. I now use this:

exiftool '-testname<${tvshow}-S${tvseason;$_=sprintf("%02d",$_)}.E${tvepisode;$_=sprintf("%02d",$_)}.%e' rename.mp4

work's incredibly. Thanks for the "push".

marsie321

Dear Phil,

I have some tif files, that are using subsectimeoriginal tag, but not with all digits.
Sub Sec Time Original           : 7

So the following command, does not work correctly
exiftool -v '-Filename<${datetimeoriginal}--${subsectimeoriginal;$_.=0 x(3-length)}.%e' -d %Y-%m-%d__%H-%M-%S .

How can I prepend zeros, instead of appending and rewrite subsectimeoriginal tag?
Sub Sec Time Original           : 7    -> Sub Sec Time Original           : 07


2021-01-20__14-23-45--700.tif (wrong)
2021-01-20__14-23-45--007.tif (would be correct)

exiftool ./2021-01-20__14-23-45--700.tif | grep -i time
File Modification Date/Time     : 2021:06:11 15:05:33+02:00
File Access Date/Time           : 2021:06:11 15:05:33+02:00
File Inode Change Date/Time     : 2021:06:11 15:16:52+02:00
Date/Time Original              : 2021:01:20 14:23:45
Sub Sec Time Original           : 7
Date/Time Original              : 2021:01:20 14:23:45.7


Thank you,
Cheers Martin

Luuk2005

Greetings Martin, please to experiment with something like... ${subsectimeoriginal; s/^(\d)$/00$1/; s/^(\d\d)$/0$1/} but not needing the spaces.
Its replacing (only-1Digit) with 001Digit, then its replacing (only-2Digits) with 02Digits
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

Phil Harvey

To prepend zeros:  ${subsectimeoriginal;$_=0 x (3-length).$_}

But I think this is wrong.  A SubSecTimeOriginal of "3" means 0.3 seconds.

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