LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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

Reply
 
Search this Thread
Old 07-11-2003, 05:22 AM   #1
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu 10.04, Debian Squeeze, Windoze 7
Posts: 512

Rep: Reputation: 34
Unhappy 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..
 
Old 07-11-2003, 10:30 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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.
 
Old 07-11-2003, 10:41 AM   #3
green_dragon37
Member
 
Registered: Oct 2002
Location: Lower Alabama
Distribution: Slackware, OpenBSD 3.9
Posts: 344

Rep: Reputation: 31
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.
 
Old 07-16-2003, 08:10 AM   #4
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu 10.04, Debian Squeeze, Windoze 7
Posts: 512

Original Poster
Rep: Reputation: 34
Cool thanks a lot

Thanks for your contribution people!!
This is surely a way to go.
 
Old 05-14-2008, 01:39 AM   #5
mojoxojom
LQ Newbie
 
Registered: May 2008
Posts: 1

Rep: Reputation: 0
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!
 
Old 05-14-2008, 08:14 AM   #6
rickh
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: Reputation: 60
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.
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ALAC & Lame Script Soulful93 Programming 6 04-15-2009 07:24 PM
Bash script to remove capitalisation and spaces form a filename scuzzman Programming 11 05-18-2008 12:28 PM
Bash script for LAME LocoMojo Linux - Newbie 6 01-09-2005 06:41 PM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
spaces in filename in console...? AlThor880 Linux - Software 4 01-09-2003 02:36 PM


All times are GMT -5. The time now is 07:00 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