I'm trying to make a loop to create directories and move files into those directories so that I can sort stuff alphabetically. Here's what I have:
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
do
mkdir $i
mv -i $i*.* ./$i/
done
ls
The issue is that the mv
command in this loop doesn't catch the uppercase file names, and I don't want to create directories for both upper and lower case file names. What's the solution? Or if you don't want to come right out and tell me the solution, where can I find it?
I've looked at a few things on google and I haven't found a solution that I could use. I'm relatively new to shell scripting, so please explain any solutions you may suggest so that I'll understand and don't have to ask a similar question later.
In bash, you can use
shopt -s nocaseglob
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With