Created
December 20, 2017 01:28
-
-
Save mikedatsko/ce17a4246c1e6c2e6cb29115807eb4c9 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
search_dir="../Pictures/untitled_folder" | |
for file in "$search_dir"/* | |
do | |
date_transfer=$(stat -f '%Sm' "$file") | |
filename=$(basename "$file") | |
extension="${filename##*.}" | |
new_name="$(date -j -f '%b %d %T %Y' "$date_transfer" '+%Y-%m-%d %H.%M.%S').$extension" | |
if [ -f "$file" ] | |
then | |
mv "$file" "$search_dir/$new_name" | |
echo "Renamed from: $file to: $search_dir/$new_name" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment