Last active
January 1, 2018 14:01
-
-
Save joegaffey/cc4350f884a5de5b62e33a33346a3404 to your computer and use it in GitHub Desktop.
Sort files into folders by month. Pass file name pattern in a parameter in quotes e.g. '*.jpg'.
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 | |
months='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' | |
echo $months | xargs mkdir | |
for month in $months | |
do | |
ls -l $1 | grep $month | awk '{print $NF}' | xargs -I {} mv {} ./$month | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment