Exact timestamp for sorting and renaming files according to
freebsd at edvax.de
Tue Jan 3 20:11:52 UTC 2012
For a sorting script, I'm currently searching for
a method to get file creation date and time as
exactly as possible. The best resolution I could
get was seconds. In case more than one file is
created within the same second, it doesn't work
precisely enough. It should work from sh script.
For the purpose of preparing the sort list (that
will be sorted and then be used as a template for
renaming the files with a prefix and a counter),
I'm using the "stat" program which creates output
% stat -f "%N %B" -t "%Y-%m-%d_%H:%M:%S" 1.txt
It's also possible to use the Epoch time format,
but it doesn't provide a solution better than
% stat -f "%N %B" -t "%s" 1.txt
I've read the manuals for stat as well as for strftime
(which is the facility stat's -t parameter addresses),
but found nothing that is more precise than seconds.
Does anyone have a suggestion how to precisely determine
the order files have been created?
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions