timo1023
November 9th, 2007, 06:30 PM
First of all, I'm a bash newb, but I'm trying to write a program to play music for me. Here it is:
#!/bin/bash
select GENRE in /Music/*$1*;
do
select ARTIST in $GENRE/*$2*;
do
select ALBUM in $ARTIST/*$3*;
do
path=$(echo $ALBUM|sed -e "s/ /\\\ /g")
vlc $path/ &
done
done
done
Here's how it works:
tmellor@tmellor:~$ music Modern Radiohead Amne
1) /Music/Modern
#? 1
1) /Music/Modern/Radiohead
#? 1
1) /Music/Modern/Radiohead/Amnesiac
#? 1
VLC media player 0.8.6c Janus
Then it plays that album. The problem is when the genre, artist, or album folder has a space, it treats the filename as two different filenames:
tmellor@tmellor:~$ music Modern Explosions
1) /Music/Modern
#? 1
1) /Music/Modern/Explosions In The Sky
#? 1
1) /Music/Modern/Explosions 3) The
2) In 4) Sky/**
#?
If I try to run sed multiple times, it just makes spaces look like this "\\ " rather than "\ ". Can I get some help with making this work?
#!/bin/bash
select GENRE in /Music/*$1*;
do
select ARTIST in $GENRE/*$2*;
do
select ALBUM in $ARTIST/*$3*;
do
path=$(echo $ALBUM|sed -e "s/ /\\\ /g")
vlc $path/ &
done
done
done
Here's how it works:
tmellor@tmellor:~$ music Modern Radiohead Amne
1) /Music/Modern
#? 1
1) /Music/Modern/Radiohead
#? 1
1) /Music/Modern/Radiohead/Amnesiac
#? 1
VLC media player 0.8.6c Janus
Then it plays that album. The problem is when the genre, artist, or album folder has a space, it treats the filename as two different filenames:
tmellor@tmellor:~$ music Modern Explosions
1) /Music/Modern
#? 1
1) /Music/Modern/Explosions In The Sky
#? 1
1) /Music/Modern/Explosions 3) The
2) In 4) Sky/**
#?
If I try to run sed multiple times, it just makes spaces look like this "\\ " rather than "\ ". Can I get some help with making this work?