Ok, after checking the "simmilar threads" results, I'm still puzzled at what I should do.
I have a shell script (someone on one of the forums I go to posted it for me) which runs through all the mp3/ogg files in the current directory and changes all the file names to lower case and replaces the spaces with an underscore { from Dude - This Rocks.mp3 to dude_-_this_rocks.mp3 }.
Handy to have, but I've got my music seperated by artist and then by album (eg. ~/music/van_halen/1984). Right now I have to go into each of the directories manually and run the script. I'd like to create another script, or add to the current one, that will allow me to start in "~/music" and go through every artist and their albums and run the script.
This is the converter script, obviously enough called mp3convert
Code:
for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done;
for i in *.ogg; do mv "$i" `echo $i | tr ' ' '_'`; done;
for i in *.MP3; do mv "$i" `echo $i | tr ' ' '_'`; done;
for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done;
for i in *.[Oo][Gg][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done;
chmod 644 *.*
So, I need a way to be able to test every file in the directory to check if it's a directory.
According to the book I"m referencing, I should use something like
Code:
if [ -d <file or directory> ]
then
cd <directory>
mp3convert;
fi
I assume I'll need to run it in a loop, too.
It's just a matter of getting the script to test the contents of the current directory.
I'll keep reading my book to see if I can figure it out. If I happen to do it before someone responds, I'll post the script here.
Thanks guys.
EDIT/UPDATE::
Ok, I can go one subdirectory deep, for example, I can run it in music/van_halen/ and it will get music/van_halen/1984 music/van_halen/balance etc. but it won't get music/van_halen/best_of_both_worlds/disc_1 or music/van_halen/best_of_both_worlds/disc_2 etc.
This is the script, so far.
Code:
#!/bin/sh
for file in *
do
if [ -d "$file" ]; then
cd "$file";
~/bin/mp3convert;
cd ..;
continue
fi
done
exit 0
I just need that last little bit to get it to go into a subdirectory, then rerun the loop to check the subdirectory for any sub-subdirectories.