[Techtalk] once again frustrated by bash :(
Angelina Carlton
brat at magma.ca
Tue Mar 9 17:32:07 EST 2004
I have a some mp3's that I got from my brother, however, his
format when he ripped them, is different than mine.
My way is to have the artist name as the directory name, then inside
that artist - songtitle.mp3
so for example the directory Propellerheads would contain files like:
Propellerheads-Take California.mp3
His method was to omit the artist name from the actual
song title.
thus his directory Propellerheads would contain
files like: Take California.mp3
So I would like to prepend the artist name to all the files
in under the artists directory.
This I thought shouldnt be too hard.
So i set about to write script, but got stonewalled right off the bat :(
I cannot see how to test if an argument is a directory or a file.
#!/bin/bash
if [ -d = "$1" ] ;
then
echo "$1 is not a directory"
else
echo "$1 is a directory"
fi
this is what I have tried, but it will tell me any argument is
a directory, even if it isnt.
if I do if [ -d != "$1" ] ;
it then tells me $1 is not a directory, even if it is.
So, I am stuck until I can find this out.
I assumed this would be the easy part :(
The rest of the script would have to read $1 and then cd into
that directory, and rename all the files.
That should be fun ;)
can anyone tell me what I am doing wrong?
thanks
aec
More information about the Techtalk
mailing list