Need help with generating m3u files in numbered directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with generating m3u files in numbered directories
# 1  
Old 09-08-2010
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 Smilie

FC12 with GNU Awk 3.1.7 & perl v5.10.0

Thank you for your time.

Last edited by Habitual; 09-08-2010 at 11:54 PM..
# 2  
Old 09-09-2010
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

# 3  
Old 09-09-2010
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

This User Gave Thanks to pludi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting - Select multiple files from numbered list

I am trying to have the user select two files from a numbered list which will eventually be turned into a variable then combined. This is probably something simple and stupid that I am doing. clear echo "Please Select the Show interface status file" select FILE1 in *; echo "Please Select the... (3 Replies)
Discussion started by: dis0wned
3 Replies

2. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

3. Shell Programming and Scripting

how to extract data from numbered files using linux in the numerical order-

Hi experts, I have a list of files containing forces as the only number as follows. Force1.txt Force2.txt Force3.txt Force4.txt Force5.txt . . . . . . . . . Force100.txt I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 .... (2 Replies)
Discussion started by: hamnsan
2 Replies

4. Shell Programming and Scripting

renaming numbered files

Hi there, I've got a set of files that are named as follows: image_N1_8letters.jpg image_N2_8letters.jpg ... image_N10_8letters.jpg image_N11_8letters.jpg .... image_N100_8letters.jpg image_N101_8letters.jpg with the "8letters" bit always consisting of 8 but always different... (3 Replies)
Discussion started by: kjartan
3 Replies

5. Shell Programming and Scripting

rename numbered files to numbered files with leading zeroes

Hi, I have some hundreds/thousands of files named logX.dat, where X can be any integer, and they are sequential, X ranges between 1 and any number: log1.dat log2.dat log3.dat log6.dat log10.dat ... log6000.dat I would like to rename them to scatter_params_0001.dat... (6 Replies)
Discussion started by: pau
6 Replies

6. UNIX for Dummies Questions & Answers

join files with numbered index

Hi all I´m a newbie so maybe this question will make someone mad. I am trying this command; join -a1 -11 file1 file2 > file3 file1 looks like: 1 2 3 4 5 6 7 8 9 10 11 file2: (4 Replies)
Discussion started by: awe1
4 Replies

7. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

8. Shell Programming and Scripting

Listing even numbered files

Hi All, Could you please help in this case? Case: there's a directory 'CKMDB' in this directory, there are 30 files named in this manner 1.txt 2.txt 3.txt .... 30.txt Could you please guide me how to list only even numbered files like 2.txt... (5 Replies)
Discussion started by: xsam
5 Replies
Login or Register to Ask a Question