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.
I seem to think you may be right about apache not liking spaces, but that might have been fixed, for now I have problems with an error message. Error messages are scary when you start looking at this stuff, it's probably simple but here it is anyhow, I called the code latest.awk, error reads...
It's a list of mp3's from the directory cut and pasted from the ls command. Sample to follow...
01___DOWNTOWN.mp3
03_SOMETHIN_STUPID.mp3
04 - Getting Old.mp3
06_STRAITEWN_UP_AND_FLY_RIG.mp3
14 - First 2 Years of Marriage.mp3
15___OYXGEN.mp3
16 - Nervous Breakdown.mp3
17.Macc Lads-Julie the Schooly.mp3
1stp Klosr (The Humble Brothers ft. Jonathan Davis).mp3
34 macc ladds - lads from mac.mp3
'39.mp3
Accelerator.mp3
After September 11th.mp3
Afx237 V7.mp3
_ Aggressive.mp3
Agua.mp3
Aim _ Cold Water Music.mp3
Airport Security.mp3
Allegretto-Quintet In E Flat, Kv452, III. Allegretto.mp3
_ Allegro (1).mp3
_ Allegro.mp3
All things dull and ugly.mp3
Always look on the bright side of life.mp3
[ always outnumbered never outgunned ].mp3
Always The Sun.mp3
Amazing.mp3
American Life.mp3
it starts looking better from here on in, the first files are my poorly named downloaded ones, the rest are rips but it's a long list, so you see why I'm reluctant to do it by hand?
Could you also try that short filelist?
I think the issue might be the weird characters later on in the file.
Save a backup of the file_list first ...
Hmm, you're long filelist works for me as well, so then the problem might be in the file: latest.awk
ok, trimmed it down, just wanted to make the point, it's a long list...
So you think I might have cut and pasted it wrong?? :S I wouldn't put it past myself, I'll check.
Nope, I get the same error message when I open it in gedit, the first print is written in black as opposed to pink which the rest of them are.
I have to put it onto a usb memory stick to transfer it from a windoze box where I am, no networking possible and my ubuntu laptop's modem is not working could something be going wrong copying it over??
awk: latest.awk:1: BEGIN{
' in expression:1: ^ invalid char '
Means some chars are not escaped that should ('39.mp3). A quick check should show what chars need replacing/removing:
Code:
find /mp3/dir -type f -iname \*.mp3 | while read l; do
[ -n "${l//[ a-z0-9._-]/}" ] && echo "\"${l}\": ${l//[ a-z0-9._-]/}"
done
Replace "/mp3/dir" with the full path leading to the directory that contains your mp3 files.
The result from your posted list shows:
Code:
"1stp Klosr (The Humble Brothers ft. Jonathan Davis).mp3": ()
"'39.mp3": '
"Allegretto-Quintet In E Flat, Kv452, III. Allegretto.mp3": ,,
"_ Allegro (1).mp3": ()
"[ always outnumbered never outgunned ].mp3": []
poorly named downloaded ones
Before generating a filelist I would rename files to something like "(album)artist_album_track_title" using mp3info (CLI) or your favourite GUI MP3 tag editing tool (also see: Freshmeat and Sourceforge). Not only is it a chance to weed out unwanted characters but it will also make the list better usable (readable).
Last edited by unSpawn; 10-23-2006 at 10:06 AM.
Reason: //add result
Unspawn, I'm having trouble getting your code going, I end up with an empty command prompt that I can't break out of, go easy on me eh? I'm very new to this...
Anyhoo, the script worked from a file_list containing all the characters that your script deems illegal, so perhaps awk can handle them anyway? (for instance one earlier script produced a file called "[always outnumbered never outgunned].html" it also has produced files containing the characters ' , ( ) _ and - )
I totally take on board the advice regarding mp3info, although I can only find an rpm (I managed to get that going using alien, then downgraded mp3info, so I had it already and didn't realise! that'll teach me!), anyone know a similar one in a deb?
Unspawn, I'm having trouble getting your code going, I end up with an empty command prompt that I can't break out of, go easy on me eh? I'm very new to this...
It was missing a ; in front of done.
Normally the syntax is while ... ; do ... ; done
Also , end each line with a bashslash (and enter) to continue on the next line with the command:
Code:
find /mp3/dir -type f -iname \*.mp3 | while read l; do \
[ -n "${l//[ a-z0-9._-]/}" ] && echo "\"${l}\": ${l//[ a-z0-9._-]/}"; \
done
Except for the last line.
This one outputs all files though, so i included the / as ok character in the fileformat:
You have to escape it so it is \/
Code:
find /mp3/dir -type f -iname \*.mp3 | while read l; do \
[ -n "${l//[ a-z0-9._-\/]/}" ] && echo "\"${l}\": ${l//[ a-z0-9._-\/]/}"; \
done
This only ouputs files with weird characters.
/edit: forgot the \/ in the end part as well ... last command is now updated.
Thanks very much for all the help guys, Tinkster, I got your code going eventually, I don't get why it didn't work on my previous trys, but I deleted a few spaces just before the first print statement and everything works just fine!
I don't understand it at all, but it is definately most useful
Awk is a text-processor that operates line(record)-oriented (by default, you
can change that, though, and make a record spawn several lines). The BEGIN
and END statements are executed before and after the processing of the file
(or STDIN) is done.
The BEGIN{ } just creates and outputs a generic HTML header (which we
redirect from the prompt) into the index.html.
The main body reads your file line by line.
This one outputs the lines for the index-file, gensub() searches each
line passed to it for \.mp3 and replaces is with \.html.
Code:
print "<li><a href=\""gensub(/\.mp3/ , ".html" , g )"\">"$0"</a>"
The next lot creates the individual files, by outputing a complete
(very basic) HTML file for a line into a file named after the target.
Btw, I just realised that the line for the index could be made shorter
and execute faster by only using the gensub once since it does the
same on both ...
many thanks for the help, I think i pm'd tinkster in particular to thank him, I used the script successfully for some time, but now I seem to have problems....
well i changed a few things and perhaps it's my fault (as is usually the case, but you guys sorted me out last time, so I thought i'd try asking the same crowd ).
anyway, my code listing looks like this these days....
As you can see, I added a couple of little changes to get the file to pick up and use a css script in every file, and the download link now leads to another file on the server to pick up a full bitrate file ( i use 32kbps for streaming, and whatever i have lying around for the download link )
But it seems to give up after doing a lot of files now it didn't used to do this! could someone help me find out where I've screwed it up this time please?
I used cygwin on xp (oh for shame!), but when I try and use the same listing on my ubuntu machine awk doesen't even get past the first line!
I use frames to put the html files in their places, well, have a poke around, and maybe a listen to a track or two, let me know where you think I might have gone wrong please.
I guess the bit where things go wrong is where awk encounters the file name millie small - my boy lollipop.mp3
it gets as far as writing "mill" at the bottom of the track listing... why would it stop there?
thanks in arrears and advance
dave
Last edited by daveoily; 10-07-2007 at 04:42 PM.
Reason: additional info
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.