Useful Shell Script to control a Rio S50 via a right-click menu

I needed something to simplify the lame -h -b 80 "File.mp3" /tmp/output.mp3 && rioutil -s "Artist Here" -t "Song Name" -r "Album Name" -a /tmp/output.mp3 that I used to use with my Rio S50.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

echo "Please answer the following questions to copy to Rio:"

echo -n "Would you like to convert this file to a lower bitrate to make the file smaller? (Y/N) "
read YNBITRATE

if [[ "$YNBITRATE" = "y" || "$YNBITRATE" = "Y" ]]
then
echo "What bitrate do you want to convert this file to?"
echo "Avaliable bitrates:"
echo "32kbps 40kbps 48kbps 56kbps 64kbps 80kbps 96kbps"
echo "112kbps 128kbps 160kbps 192kbps 224kbps 256kbps 320kbps"

echo -n "Enter a bitrate: "
read BITRATE
fi

id3info "$@"

echo "ID3 info will be lost while copying, please reenter the following information:"

echo -n "Song Name : "
read SONG

echo -n "Artist : "
read ARTIST

echo -n "Album : "
read ALBUM

echo

if [[ "$YNBITRATE" = "y" || "$YNBITRATE" = "Y" ]]
then
echo "Reencoding at $BITRATE kbps"
lame -h -b $BITRATE "$@" /tmp/output.mp3

echo "Now copying file to Rio (requires root access):"
sudo rioutil -s "$ARTIST" -t "$SONG" -r "$ALBUM" -a /tmp/output.mp3
else
echo "Now copying file to Rio (requires root access):"
sudo rioutil -s "$ARTIST" -t "$SONG" -r "$ALBUM" -a "$@"
fi

echo "Press any key to continue."
read BYE

Then I right-clicked on an MP3, open with > other application > gnome-terminal -x copytorio (I put the shellscript in /usr/bin). And it should work if I plug it in.