Last active
January 1, 2018 14:03
-
-
Save joegaffey/1c477b4c9210153cbc6cd9fb2f1a6683 to your computer and use it in GitHub Desktop.
Sort files into folders by month number. Pass file name pattern in a parameter in quotes e.g. '*.jpg'.
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 | |
months=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) | |
monthNums='01 02 03 04 05 06 07 08 09 10 11 12' | |
echo $monthNums | xargs mkdir | |
i=0 | |
for monthNum in $monthNums | |
do | |
ls -l $1 | grep ${months[$i]} | awk '{print $NF}' | xargs -I {} mv {} ./$monthNum | |
let "i++" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment