Created
January 11, 2017 14:17
-
-
Save Phlow/896649b31202cc888f0819b3d266496d to your computer and use it in GitHub Desktop.
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`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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