After taking a look at this answer and adapting to my needs, I am stuck when there are files with identical timestamps.
I need to rename all files in a folder, including the date and timestamp at end. However, if any two files share the same date and timestamp, then my shell script doesn't work property. In that case, I thought the best solution would be to add a number, incrementing by one, each time there is a file with an identical timestamp.
The files should look like this:
photo_2019_12_23_22_20_35_001.jpg
photo_2019_12_23_22_20_35_002.jpg
photo_2019_12_23_22_20_35_003.jpg
photo_2019_12_23_22_20_36_001.jpg
Here is the code as I have it now:
for f in *.*; do
mv -n "$f" "photo-$(stat -f'%SB' -t "%Y_%m_%d_%H_%M_%S" "$f").${f##*.}"
done
sum
. Or the first few characters ofmd5
.