jamesisin
February 23rd, 2010, 01:24 AM
I am writing a script to sync playlists onto a music device.
I have some code which will give me a list of user-generated playlists:
PLAYLISTS=$( grep playlist\ name.*type=\"static\" $RHYTHMBOXLISTS | awk -F '"' '{ print i$2 }' )
The variable $RHYTHMBOXLISTS is the location of the playlists file:
RHYTHMBOXLISTS="/home/$USER/.gnome2/rhythmbox/playlists.xml"
Running the code under PLAYLISTS (ie, that which resides in the parentheses) returns a list of the names of the playlists which the user has created using Rhythmbox.
grep playlist\ name.*type=\"static\" /home/username/.gnome2/rhythmbox/playlists.xml | awk -F '"' '{ print i$2 }'
_0_0_Burn_0_0_
_0_0_RockBox1
_0_0_RockBox2
_0_j2 [16]
_1_2_BeattlesCovers
...
I would like to put selectable numbers before each playlist. I tried using select:
select SYNKLIST in "$PLAYLISTS"; do
echo "You chose "$SYNKLIST", processing..."
done
The problem is that the list gets transformed somewhere. As written above I get a one item list which gives the entire list (with line breaks, but all one item). If I remove the quotes around $PLAYLISTS I get a list of each space separated word (no longer broken at the line breaks in the grep list):
./RockBoxSynk.sh
...
1) _0_0_Burn_0_0_
_0_0_RockBox1
_0_0_RockBox2
_0_j2 [16]
_1_2_BeattlesCovers
or
./RockBoxSynk.sh
...
1) _0_0_Burn_0_0_ 51) Slow
2) _0_0_RockBox1 52) Fire
3) _0_0_RockBox2 53) [16]
4) _0_j2 54) Digital
5) [16] 55) Dawn
6) _1_2_BeattlesCovers 56) [13]
Am I going about this all wrong? What is the best solution?
I would like the user to be able to select one or more playlist from the list (with options to QUIT and select ALL).
I have some code which will give me a list of user-generated playlists:
PLAYLISTS=$( grep playlist\ name.*type=\"static\" $RHYTHMBOXLISTS | awk -F '"' '{ print i$2 }' )
The variable $RHYTHMBOXLISTS is the location of the playlists file:
RHYTHMBOXLISTS="/home/$USER/.gnome2/rhythmbox/playlists.xml"
Running the code under PLAYLISTS (ie, that which resides in the parentheses) returns a list of the names of the playlists which the user has created using Rhythmbox.
grep playlist\ name.*type=\"static\" /home/username/.gnome2/rhythmbox/playlists.xml | awk -F '"' '{ print i$2 }'
_0_0_Burn_0_0_
_0_0_RockBox1
_0_0_RockBox2
_0_j2 [16]
_1_2_BeattlesCovers
...
I would like to put selectable numbers before each playlist. I tried using select:
select SYNKLIST in "$PLAYLISTS"; do
echo "You chose "$SYNKLIST", processing..."
done
The problem is that the list gets transformed somewhere. As written above I get a one item list which gives the entire list (with line breaks, but all one item). If I remove the quotes around $PLAYLISTS I get a list of each space separated word (no longer broken at the line breaks in the grep list):
./RockBoxSynk.sh
...
1) _0_0_Burn_0_0_
_0_0_RockBox1
_0_0_RockBox2
_0_j2 [16]
_1_2_BeattlesCovers
or
./RockBoxSynk.sh
...
1) _0_0_Burn_0_0_ 51) Slow
2) _0_0_RockBox1 52) Fire
3) _0_0_RockBox2 53) [16]
4) _0_j2 54) Digital
5) [16] 55) Dawn
6) _1_2_BeattlesCovers 56) [13]
Am I going about this all wrong? What is the best solution?
I would like the user to be able to select one or more playlist from the list (with options to QUIT and select ALL).