Created
August 20, 2017 00:07
-
-
Save sirianni/9739b345bee072a4bfaa5b3de3019ea1 to your computer and use it in GitHub Desktop.
Organize files into subdirectories by year
This file contains hidden or 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 | |
for f in `ls -p | grep -v /`; do | |
file="$f" | |
modtime=`stat --format=%Y "$file"` | |
year=`date --date @$modtime +%Y` | |
if [ ! -d "$year" ]; then | |
mkdir -p "$year" | |
fi | |
echo "Moving $file to $year..." | |
mv "$file" "$year/" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment