Skip to content

Instantly share code, notes, and snippets.

@sh78
Created March 25, 2017 00:49
Show Gist options
  • Save sh78/9946c06c1af0991b8f8600f338d70aa2 to your computer and use it in GitHub Desktop.
Save sh78/9946c06c1af0991b8f8600f338d70aa2 to your computer and use it in GitHub Desktop.
rename files prepending creation date to name
#!/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