Rename file names in directory to creation timestamp with second precision Is there an easy way to do this for files in a particular directory - to have their names be renamed to the file timestamp, with seconds level precision

Clarification: 

For example, suppose a (Mac 10.14.15) directory has the following files, where the notation below shows original file name and file creation time. (But, to be clear, we are working from the Mac file directory, and not from the luxury of just parsing thru a text file.) The filenames are uuid 36 character names:


35eafb32-8005-11e9-bc42-526af7764f64.png 09:35:01
419f0eb4-8005-11e9-bc42-526af7764f64.png 09:35:11
43249984-8005-11e9-bc42-526af7764f64.png 21:02:03


Suppose I want to rename the files based on (original creation) timestamp, but the filename of course has to be in an acceptable format: 


prepend-09_35_01.png
prepend-09_35_11.png
prepend-21_02_03.png


(In the actual case, the directory has 2000+ files. If it matters, they are transported from an iPhone X app I made - through iTunes file sharing. The file creation date and time shows up correctly on Mac when transferred.)
If all the files are in the same directory, then in Terminal, changed directory, e.g. cd /path/to/directory and then use the following compound command:

for f in *.*; do echo mv -n "$f" "${f%.*}-$(stat -f'%SB' -t "%H_%M_%S" "$f").${f##*.}"; done


Note: There is an intensional echo command that is there for you to test with, and it will only print out the mv command for you to see that it's the outcome you wish. You can then run it again removing just echo from the compound command to actually rename the files as desired via the mv command.


Example:

$ touch 35eafb32-8005-11e9-bc42-526af7764f64.png 419f0eb4-8005-11e9-bc42-526af7764f64.png 43249984-8005-11e9-bc42-526af7764f64.png
$
$ ls -1
35eafb32-8005-11e9-bc42-526af7764f64.png
419f0eb4-8005-11e9-bc42-526af7764f64.png
43249984-8005-11e9-bc42-526af7764f64.png
$
$ for f in *.*; do echo mv -n "$f" "${f%.*}-$(stat -f'%SB' -t "%H_%M_%S" "$f").${f##*.}"; done
mv -n 35eafb32-8005-11e9-bc42-526af7764f64.png 35eafb32-8005-11e9-bc42-526af7764f64-19_56_35.png
mv -n 419f0eb4-8005-11e9-bc42-526af7764f64.png 419f0eb4-8005-11e9-bc42-526af7764f64-19_56_35.png
mv -n 43249984-8005-11e9-bc42-526af7764f64.png 43249984-8005-11e9-bc42-526af7764f64-19_56_35.png
$
$ for f in *.*; do mv -n "$f" "${f%.*}-$(stat -f'%SB' -t "%H_%M_%S" "$f").${f##*.}"; done
$
$ ls -1
35eafb32-8005-11e9-bc42-526af7764f64-19_56_35.png
419f0eb4-8005-11e9-bc42-526af7764f64-19_56_35.png
43249984-8005-11e9-bc42-526af7764f64-19_56_35.png
$ 




Understanding the bash compound command:


for f in *.*; do ...; done &nbsp;&nbsp; For every file in the current dir do the following command(s) to them.
echo &nbsp;&nbsp; Print what follows. (Must be removed for the mv command to actually work.)
mv -n source target &nbsp;&nbsp; Move files, do not overwrite an existing file, filename, new filename.


"$f" &nbsp;&nbsp; The source filename.
"${f%.*}-$(stat -f'%SB' -t "%H_%M_%S" "$f").${f##*.}" &nbsp;&nbsp; The target filename.
${f%.*} &nbsp;&nbsp; Name portion of the filename without the extension. See Parameter Expansion in the bash man page.
- &nbsp;&nbsp; The HYPHEN-MINUS character.
$(...) &nbsp;&nbsp; Command Substitution, allows the output of a command to replace the command name.
stat -f'%SB' -t "%H_%M_%S" "$f"
stat &nbsp;&nbsp; Display file status. See its man page for more details.
-f'%SB' &nbsp;&nbsp; −f format &nbsp;&nbsp; Display information using the specified format. See the FORMATS section for a description of valid formats. In this case %SB represents string output of the birth time of the inode. (The time the file was created.)
-t "%H_%M_%S" &nbsp;&nbsp; −t timefmt &nbsp;&nbsp; Display timestamps using the specified format. This format is passed directly to strftime(3). In this case it represents the hour, a LOW LINE character (AKA underscore), the minute, a LOW LINE character, the second.
%H &nbsp;&nbsp; Is replaced by the hour as a decimal number (00-23).
%M &nbsp;&nbsp; Is replaced by the minute as a decimal number (00-59).
%S &nbsp;&nbsp; Is replaced by the second as a decimal number (00-60).
"$f" &nbsp;&nbsp; The source filename.
. &nbsp;&nbsp; The FULL STOP character. (AKA dot or period.)
${f##*.} &nbsp;&nbsp; The extension portion of the filename. See Parameter Expansion in the bash man page.



Note that the upper case character names are that which show in Character Viewer on a US English install of macOS.