Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
When renaming files in terminal, you can use their time stamp. This bash/shell script helps you. It uses `stat` to get the information, formats the time stamp with `date` and renames each file with `mv`.
#
# When renaming files in terminal, you can use their time stamp. This bash/shell script helps you.
#
# One liner: for f in *.jpg; do D=$(date -r $(stat -f %B $f) +%Y-%m-%d-%H-%M-%S); mv -vi "$f" "$D-$f"; done
for datei in *.jpg
do VARIABLE_WITH_FORMATTED_DATE=$(date -r $(stat -f %B $datei) +%Y-%m-%d-%H-%M-%S)
mv -vi "$datei" "$VARIABLE_WITH_FORMATTED_DATE-$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment