Scripts and stuff
Scripts and stuff
Since there are scattered posts all over the place about script files, I think it would be best to keep them all confined here from now on. Just to make it easier to follow it all. I'd split the other topics, but then all the posts and stuff would seem a bit out of place.
I'm currently trying to work on one that looks at all the files in $PWD and sorts them into ./music/ and ./pictures/ folders depending on their filetypes... And since I'm lazy and don't usually add extensions to my image files, it makes my life that much more fun. lol
I still have to add in the checks to see if ./music/ and ./pictures/ exists... and to make them if they don't.
Code: Select all
#/bin/bash
#Scattered Media Sorter Upper
if [ $(file "$i" | grep "image data") ]; then
mv "$i" pictures
fi
if [ $(file "$i" | grep "Audio file") ]; then
mv "$i" music
fi
That is some bad coding there. Better use a case-construct:
Any fool can write code a computer can understand. It takes an expert to write code humans can understand
Code: Select all
case "$(file "$i")" in
*"image data"* | *"bitmap data"* )
mv "$i" pictures/
;;
*"Audio file"* )
mv "$i" music/
;;
esac
DOSBox ReadMe | DOSBox Wiki | DOSBox 60 seconds guide | How to ask questions
_________________
Shuttle SN41G2 | Athlon XP 2600+ | IGP@128 MB | NEC 3520A DVD | Win XP Home/SP2
_________________
Shuttle SN41G2 | Athlon XP 2600+ | IGP@128 MB | NEC 3520A DVD | Win XP Home/SP2