I’ve a huge amount of png files, which are named the following way: PREFIX_00000000.png
Where PREFIX_
is a fixed string and is followed by eight numbers (maybe anyday more). These numbers represent milliseconds.
Now i’m searching for a way to convert the filename from the given format to the format PREFIX_HH:mm:ss.ffff.png
. (String, followed by Hour:Minute:Second.Millisecond).
The turnside? This should be done via bash (Ubuntu).
Did anyone of you do sth like this? Or does have a solution?
2
Answers
Using any awk:
Remove the
echo
once you’re happy with the results.Check the math and tweak if necessary as I mostly just copied it from From milliseconds to hour, minutes, seconds and milliseconds.
You used "milliseconds" but gave 4 digits after the decimal. If you really intended 4 digits, replace
1000
with10000
,???
with????
, and%03d
with%04d
(or append a fixed0
if it actually is milliseconds but you still want 4 digits).