Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-08-2010
Habitual's Avatar
Registered User
 

Join Date: Jun 2008
Location: Youngstown, OH
Posts: 110
Thanks: 22
Thanked 5 Times in 5 Posts
Need help with generating m3u files in numbered directories

Hello:

First, I have no idea what to search for on this task, so I'll just spell it out.
I have the Bible in Audio format and each book is in a directory of it's own.
01 to 66 accordingly.

I need a script to walk through each of them and ls *.mp3 > directory|book.m3u without the preceding directory numbers.

list.txt partially contains:
01. Genesis
02. Exodus
03. Leviticus
04. Numbers
05. Deuteronomy
06. Joshua
07. Judges
08. Ruth
09. Samuel I
10. Samuel II

simple.txt contains
Genesis
Exodus
Leviticus
Numbers
Deuteronomy
Joshua
Judges
Ruth
Samuel I
Samuel II

Desired output:
Genesis.m3u
Exodus.m3u
Leviticus.m3u
Numbers.m3u
Deuteronomy.m3u
Joshua.m3u
Judges.m3u
Ruth.m3u
Samuel I.m3u
Samuel II.m3u

inside each of the 66 directories.

and optionally, a single m3u file that contains the contents of all 66 directories.

This is NOT homework, not even for a seminary student

FC12 with GNU Awk 3.1.7 & perl v5.10.0

Thank you for your time.

Last edited by Habitual; 09-08-2010 at 10:54 PM..
Sponsored Links
    #2  
Old 09-09-2010
rdcwayx rdcwayx is offline Forum Advisor  
Use nawk in Solaris
 

Join Date: Jun 2006
Posts: 2,632
Thanks: 43
Thanked 383 Times in 373 Posts
Can you explain more clearly what you need to do.

Just for start:

if you got txt file list.txt, and you need the Desired output, you can run:


Code:
awk -F \. '{print $2 ".m3u"}' list.txt

Sponsored Links
    #3  
Old 09-09-2010
pludi's Avatar
pludi pludi is offline Forum Staff  
Cat herder
 

Join Date: Dec 2008
Location: Vienna, Austria, Earth
Posts: 5,486
Thanks: 38
Thanked 324 Times in 301 Posts
This should do (needs bash or a current version of ksh):
Code:
find . -type f -name '*.mp3' -print | \
sort | \
while read path; do 
    dir=$( dirname "$path" );
    file=$( basename "$path" );
    m3u=${dir#./[0-9][0-9]. };
    echo "$file" >> "$dir/$m3u.m3u";
    echo "${path#./}" >> all.m3u;
done

The Following User Says Thank You to pludi For This Useful Post:
Habitual (09-09-2010)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Listing even numbered files xsam Shell Programming and Scripting 5 12-09-2009 06:56 AM
Generating an xml having information related to files in the directory abhinav192 Shell Programming and Scripting 8 11-19-2009 10:31 AM
Generating formatted reports from log files daccad Shell Programming and Scripting 5 07-28-2009 03:48 AM
Generating files. anushree.a Shell Programming and Scripting 8 09-22-2008 07:49 AM
Generating files of specific size nxd25 Shell Programming and Scripting 2 06-27-2006 11:06 AM



All times are GMT -4. The time now is 04:13 AM.