LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-05-2008, 12:43 PM   #1
sthompson
LQ Newbie
 
Registered: Jun 2008
Posts: 11

Rep: Reputation: 0
script for compiling a playlist


ok i use liquidsoap to play a stream of music and i have created a script to make a playlist and i was woundering how to get the list to form in alphebetical order right now i have

find /icecast -name '*.mp3' > /test.txt

and that compiles a random list of the mp3's
what would i have to add for it to be alpebetical??
 
Old 06-05-2008, 12:54 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Pipe the output of find to sort
Code:
find /icecast -name "*.mp3" | sort > /test.txt
 
Old 06-05-2008, 12:57 PM   #3
sthompson
LQ Newbie
 
Registered: Jun 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks that was simple and quick thanks colucix

do you know if there was a way i could get a file to insert in to the play list in between each
ex:

1broadcast.mp3
annoucment.mp3
2broadcast.mp3

i ask this cause all my mp3's are dated and i would like to insert a annoucement between them

Last edited by sthompson; 06-05-2008 at 01:01 PM.
 
Old 06-05-2008, 02:31 PM   #4
sarin
Member
 
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
Save the below lines in a file (say song.sh)
After changing the permissions etc, do ./song.sh < test.txt

lines=`wc -l test.txt | cut -f 1 -d" "`
while [ $lines -gt 0 ]
do
read song
echo $song
echo /path/ann.mp3
lines=`expr $lines - 1 `
done


(Hmm... I think I feel really bored today )
 
Old 06-05-2008, 03:25 PM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Do you want to insert the same line "announcement.mp3" between each line? You can do in many ways using sed or awk one-liners, for example:
Code:
awk '{print; print "announcement.mp3"}' test.txt
with awk you have to redirect the output to a file and then substitute the original one. Instead, with the following sed command you can use the -i option to edit the file in place, substituting the end of line with a newline character followed by the string "announcement.mp3":
Code:
sed -i 's/$/\nannouncement.mp3/g' test.txt
I'm sure there are better and more elegant ways to do the same, anyway. Cheers!
 
Old 06-05-2008, 03:42 PM   #6
sthompson
LQ Newbie
 
Registered: Jun 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks guys i'll test them when i get a chance
 
Old 06-05-2008, 04:49 PM   #7
sthompson
LQ Newbie
 
Registered: Jun 2008
Posts: 11

Original Poster
Rep: Reputation: 0
with the sed command what is the change to make it every 2 lines or more
 
Old 06-05-2008, 06:38 PM   #8
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Code:
sed -i '0~3{s/$/\nannouncement.mp3/}' test.txt
This executes the substitution every three lines starting from zero. The 0~3 part is the address in the form M~N, where M is the starting line and N the step. You can play with different values to see how it works, but you actually need to change the step only, to make it every 2 lines or more.
 
Old 06-05-2008, 07:34 PM   #9
sthompson
LQ Newbie
 
Registered: Jun 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks again colucix
 
  


Reply

Tags
scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] Script for automated compiling hbinded Programming 10 08-22-2006 04:30 AM
Ices config - script for playlist section acc92 Linux - Software 1 05-11-2005 03:53 AM
mplayer playlist or script help gotcha Linux - Software 0 09-02-2004 09:08 AM
A Program/script making a html playlist? Trinity22 Linux - Software 4 04-13-2004 10:29 PM
Automating a playlist using shell script... DesiLILO Linux - Newbie 4 04-03-2004 12:03 AM


All times are GMT -5. The time now is 03:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration