Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-11-2003, 05:22 AM
|
#1
|
|
Member
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu 10.04, Debian Squeeze, Windoze 7
Posts: 506
Rep:
|
Script: lame stumbles on spaces in filename
I am just writing a script for enconding whole directories of .wav into mp3 with lame.
Now I am not a script wizard, far from it actually. I could find a script like this on the web with no problem, but I like to learn how to write this myself, so that is why I ask you.
When I execute:
lame -h directoryOfWavs/*
lame stumbles over files with names like
Oh I love you so much bla bla.wav
because it thinks that these are seperate arguments (Oh, I, love, you, etc...)
lame -h "directoryOfWavs/*"
does not work. Now I guess I need to write a script that makes like a ls of the dir and then goes through every entry and executes lame, with the name in " ".
Is there another way to do this, easier?
Or can maybe somebody point me to a script that does this, so I can analyze it?
Other question: how do you guys ENCODE your .wavs?
I mean, not rip and then encode, just encode, lot's of wavs, without typing every command seperately?
I checked out many tool, some of them with guis and they usualy only like to compress what they ripped first, there seems little ways to insert "coockoo" wavs that then get encoded.
Thanks in advance for any suggestions or pointers..
|
|
|
|
07-11-2003, 10:30 AM
|
#2
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
Typically a space is used as the delimiter when a program/script looks at its arguments. Also, when you use a wildcard on the command line, the shell expands it before passing it to the executable. Those two things combine to give you your current problem.
You can prevent expansion by putting your wildcard in single quotes, like '*.wav', but that only solves part of the problem. lame will then look for a file literally named *.mp3 which is not what you want either.
Read the man page for the find command ( man find). You're mainly interested in the -exec argument. This might work for your purposes:
find . -name "*.[Ww][Aa][Vv]" -print -exec lame -h {} \;
That will look for each file with a .wav extension (in any combination of upper and lowercase letters) in the current directory and any subdirectories, print the match when it finds one, and then run lame on each match.
It will put the new mp3 file in the directory you run the command from.
If this helps, you can thank whansard... he and I collaborated on another similar thread. It looks like I beat him to the punch again...
The other thread
Last edited by Dark_Helmet; 07-11-2003 at 11:37 AM.
|
|
|
|
07-11-2003, 10:41 AM
|
#3
|
|
Member
Registered: Oct 2002
Location: Lower Alabama
Distribution: Slackware, OpenBSD 3.9
Posts: 344
Rep:
|
Another option would be to simply change all of the spaces in the filenames to underscores, with the following:
Code:
for i in *.[Ww][Aa][Vv]; do mv "$i" `echo $i | tr ' ' '_'`; done
And then do lame.
Ian
Last edited by green_dragon37; 07-11-2003 at 10:50 AM.
|
|
|
|
07-16-2003, 08:10 AM
|
#4
|
|
Member
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu 10.04, Debian Squeeze, Windoze 7
Posts: 506
Original Poster
Rep:
|
thanks a lot
Thanks for your contribution people!!
This is surely a way to go.
|
|
|
|
05-14-2008, 01:39 AM
|
#5
|
|
LQ Newbie
Registered: May 2008
Posts: 1
Rep:
|
More examples since this thread still hits on searches
I've been working on my own script, and it is only the very basics just now but I hope to expand on it (passing args/adding switches for recursion), who knows maybe even globbing. Anyway the command is wav2mp3 and is a bash shell script...
Code:
#!/bin/bash
find . -name "*.wav" -type f -print|xargs -I % basename % .wav|xargs -I % lame -V 0 --vbr-new --clipdetect --verbose %.wav %.mp3 ;
I struggled with this command for a long time. There are many spaces in the song names I'm trying to process, just as you folks are. And of course you know the enless troubles.
The big break for me was passing the output to basename first (using xargs), then taking that ouput, piping it again and using xarg's selectable insertion character (I chose %; -I % above) I added the proper extensions on where I needed the extensions back. Trying to keep the .wav on the end and stripping it in-place where I wanted to substitute .mp3 was proving to be a pain. Having the filename already set to basename before xargs tries to pass it to lame is much simpler. If I remember, I'll try to post updates here. This thread came up pretty high on Google's search, even though it's several years old now.
Peace!
|
|
|
|
05-14-2008, 08:14 AM
|
#6
|
|
Senior Member
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250
Rep:
|
Reviving old thhreads like this is just a bad bad policy. There are plenty of newer threads addressing these issues more successfully than the one you dredged up. Best bet is to start a new thread with whatever issues you are currently having, and let the helpful folks here take it from there.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:51 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|