Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello im trying to make a menu type mp3 playist program from a bash script. im stuck on assigining the menu the variable. Please if anyone can throw some feedback whats wrong here thanks in advance.
im using mplayer and playlist needs to reside in
/home/Fedora11 and mp3 will reside in /home/Fedora11/MP3
Code:
#!/bin/bash
PLAYLIST='/home/Fedora11'
mk_playlist()
{
AUDIOPATH=$PLAYLIST/MP3
find "$AUDIOPATH" -type f -name '*.[Mm][Pp]3' > /home/Fedora11/playlist
while : #This always returns true (see /bin/true and :)
do
echo -e 'Mp3 Playlist Program:
================================
C)reate Mp3 Playlist
E)dit Mp3 Playlists
D)isplay Mp3 Playlists
G)enerate Mp3 Database
P)lay Mp3
1)Copy Mp3
2)Remove Mp3
Q)uit
Enter your selection ==> \c'
read ANS
case "$ANS" in
c | C ) echo e- "Create A Play List? --> \c"
read CREATEPLAYLIST
echo -e "$CREATEPLAYLIST" >> /home/Fedora11
;;
esac
done
First of all you forgot to close the function definition of mk_playlist().
What is this line supposed to do?
Im not sure?? im a newb.. Im very frusterated upon hours of reasearching and reading.. I am just trying to do this the best way i been taking bits and pieces from what people are telling me to do..
I need to create a playlist menu. list i have put in the script.
be able to read the mp3 in /home/Fedora11/mp3 and make a playlist
in /home/Fedora11 but i have the sligtest clue even where to start??
Im not sure?? im a newb.. Im very frusterated upon hours of reasearching and reading.. I am just trying to do this the best way i been taking bits and pieces from what people are telling me to do.
Welcome to LQ
Relax. Smile. Count to 100 while breathing deeply
Surely we can help you. The first step is to be very clear about what you want to do. We're pretty smart but not mind readers so you are going to have to tell us. You're new to all this and probably don't know exactly what you want to do but that's OK -- we can work together on that. Tell us the best you can, tell us what you are uncertain about and we can go forward from there.
ok i am using mplayer.
i would like the ability to create display and remove playlists.
Playlist will reside in /home/Fedora11 and the mp3s are in
/home/Fedora11/MP3
I also need a database file that shows the path directory.
ability to play mp3 and add mp3 to the playlist and check for duplicates.
I want it in sort of a menu type options something like this
Code:
## Functions for each task
create_playlist() {
: put appropriate commands here
}
edit_playlist() {
: put appropriate commands here
}
delete_playlist() {
: put appropriate commands here
}
generate_playlist() {
: put appropriate commands here
}
play_mp3() {
: put appropriate commands here
}
copy_mp3() {
: put appropriate commands here
}
delete_mp3() {
: put appropriate commands here
}
## Print menu and execute user's selection
while :
do
printf %s '
Mp3 Playlist Program:
================================
C)reate Mp3 Playlist
E)dit Mp3 Playlists
D)isplay Mp3 Playlists
G)enerate Mp3 Database
P)lay Mp3
1)Copy Mp3
2)Remove Mp3
Q)uit
Enter your selection ==> '
read ANS
case "$ANS" in
c|C ) create_playlist ;;
e|E ) edit_playlist ;;
d|D ) delete_playlist ;;
g|G ) generate_playlist ;;
p|P ) play_mp3 ;;
1) copy_mp3 ;;
2) delete_mp3 ;;
q|Q ) exit ;;
esac
done
I have been bouncing back from forums and reading but really unsure what the next step to acutally make the options work. If i could get one to work i could try to geth the others to work..
Also a friend said that this has to be linear so the first part of the script has to come after the menu??
Ok i got some progress here. Tackled the play mp3 so far
modded it a bit with litle help i added this cmd but it doesnt like when i enter in songs with spaces how can i fix this??
Code:
play_mp3() {
cd /home/Fedora11/MP3/
ls -v *.mp3
echo -e
echo -e "Please Select Your Song --> \c"
read SONG
mplayer $SONG
}
You could create a temp file with a directory listing. Then you can read the file line by line to see if the file exist. If it does, then do nothing, if it doesn't then copy the file.
Code:
copy_mp3() {
cd /home/Fedora11/MP3/
ls -v *.mp3 >> /home/Fedora11/MP3/tempdir.lst # Create Temp file with Directory listing
echo -e "Please Select Your Song To Copy --> \c"
read DONKEY
cat /home/Fedora11/MP3/tempdir.lst | while read line; do #Read each line of the file and store the line to $line variable
if $line == $DONKEY then
echo "File Already Exist, Copy Aborted!"
else
cp $DONKEY /home/Fedora11/MP3_1/
done
rm /home/Fedora11/MP3/tempdir.lst # Delete the temporary file containing the directory listing
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.