I’ve always been a fan of collecting fonts, as I go across the net I find random font files and save them for later use. Seems like I can never find the fonts I want because they are scattered all over and unsorted. Got tired of having unorganized font files laying around, so I wrote this to organize them.
#!/bin/bash
#Edit path to the location of where you want your fonts organized
#create a folder called "Unsorted" and place all the files into that.
path="Fonts/"
cd "${path}Unsorted/"
for mFile in *
do
#Check rather its a file or folder, if its a folder skip it!
if ! [[ -f $mFile ]]; then continue; fi
#Grab the first letter of the filename and set it to $mFirstChar/
mFirstChar="${mFile:0:1}"
#Convert all lowercase fist letters to upper case.
mFL=$(tr "[:lower:]" "[:upper:]"<<<"$mFirstChar")
#If the filename contains any chars such as "!@#$%^&*()" at the beginning
# set the $mFl var to "MSC".
if [[ $mFL != [[:alpha:]] ]]; then mFL="MSC"; fi
#Make directories, prompt for overwrite and create dir if it does not exists.
mkdir -ip "../${mFL}"
#Move files to there new home.
mv -v "${mFile}" "../${mFL}/${mFile}"
done