Personally, I'm thinking that the use of lame, Audacity and whether they're mp3 files is irrelevant to your problem. How about posting the stricken script so that someone can review/correct the loop that's misbehaving...?
okay, so the sequence you'd said was required earlier is not what the script you've posted is actually doing. You have them separated into two loops, which is fine, but might be off in terms of timing...maybe you're checking in on the results before the first loop is completed...
Assuming that lame takes your hello.WAV file and outputs it as hello.MP3, try:
#!/bin/bash
cd ~/Documents
for file in *.wav
do
lame "$file"
mv ${file%.wave}.mp3 ~/Documents/newmp3s/.
done
cd -
I tried your solution and it only saved my 2 test files (Hello1.wav and Hello2.wav) in ~/Documents as *.wav.mp3 files, still in ~/Documents.
I tried putting the idea from your code into my previous code and it worked.
Here is the new code:
#!/bin/bash
cd ~/Documents
for file in *.wav;
do lame "$file";
for i in *.wav.mp3 ; do
mv "$i" ~/Documents/'newmp3s'
cd ~/Documents/'newmp3s'
rename 's/.wav//' *.mp3
cd ..
done
done
Thanks for that.
But now if i want to convert mp3s into mp3s (i do that to decrease file size), using exactly the same code, the 'rename' command will remove the 'mp3' extension in all but the last new converted file in ~/Documents/newmp3s. Any workaround for that?
#!/bin/bash
cd ~/Documents
for file in *.mp3;
do lame "$file";
for i in *.mp3.mp3 ; do
mv "$i" ~/Documents/newmp3s
cd ~/Documents/newmp3s
rename 's/.mp3//' *.mp3
cd ..
done
done
Does lame care about the input file's extension; ie, takes your input file as is and bases processing on file structure instead of extensions? If so, why not strip it off (or do a temporary cp) prior to passing it to lame, and then do the rename to .MP3 as per usual?
and i got 'Warning: Unsupported audio format' even though 'hello' is of mp3 format.
I would just like to replicate the 'one-click conversion' from the audio converters in Windows, without installing software.
I can still add the 'mp3' extension in all files after conversion, that's no biggie.
---------- Post updated at 04:02 PM ---------- Previous update was at 11:58 AM ----------
I also noticed that all the songs in my Music Library does not include the '.mp3' extension in their filename :S
I copied 2 songs to ~/Documents and my script bypassed those 2 files because lame does not recognize them as mp3s. Audacity does though and it still uses lame for encoding.
I think it's getting too complicated now. I'll just look for a program that does batch encoding in *nix.
--mp3input
Assume the input file is a MP3 file. Useful for downsampling from one mp3 to
another. As an example, it can be useful for streaming through an IceCast server.
If the filename ends in ".mp3" LAME will assume it is an MP3 file. For stdin or
MP3 files which do not end in .mp3 you need to use this switch.
That option may help you out. If you want further help with your script, add "set -x" as the first command and then post the trace output that's generated.
and it worked. The output file was fine when i put back the mp3 extension. Thanks a lot.
But, in my script, i already specified in the for loop to only consider '.mp3' files. It will still ignore 'non-mp3' files. How do i make it detect any audio file of mp3 format in ~/Documents?
As for adding 'set -x', my script closes itself when all conversion is done. How do i stop that?
#!/bin/bash
set -x
cd ~/Documents
for file in *.mp3;
do lame --mp3input "$file";
for i in *.mp3.mp3 ; do
mv "$i" ~/Documents/newmp3s
cd ~/Documents/newmp3s
rename 's/.mp3//' *.mp3
cd ..
done
done