Created
March 25, 2017 00:49
-
-
Save sh78/9946c06c1af0991b8f8600f338d70aa2 to your computer and use it in GitHub Desktop.
rename files prepending creation date to name
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
#!/bin/bash | |
# prepend creation date to file names in format `YYY-MM-DD original_file_name` | |
for file in *; do | |
thedate=$(date -r $(stat -f %B "$file") +%Y-%m-%d) | |
echo "renaming \"$file\" to \"$thedate $file\"" | |
mv -v "$file" "$thedate $file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment