Link to home
Start Free TrialLog in
Avatar of Matt330
Matt330Flag for United States of America

asked on

Linux: How do I convert all wav files in multiple subdirectories to mp3 without having to cd to each individual directory?

I decided some time ago to save all my cd's in WAV format as a backup and now I'd like to convert to mp3 to keep on my laptop and not take up so much space.  The music is in directory /home/me/wav/band/album/song.wav

Is there a way to convert the entire all wav files from the command line at from the ~/wav directory.

I was using this:

for i in *.wav; do     lame -h -b 192 "$i" "${i%.wav}.mp3"; done

but I have to cd to the album for every individual album I want to convert.

Further (and probably less likely) - is there a way to do this, and file these in the exact same way as the wav files except in an "mp3" folder.  IN other words, copy the actual folders and subfolders?

THANKS!
Avatar of Matt330
Matt330
Flag of United States of America image

ASKER

After searching around more, I think there may be two solutions (I only post them prior to trying because I feel like it may clarify the original question - I'll update if they work).

1.  I'm hopeful the following will work to convert all in a single directory "mp3"

a=$(find /home/me/wav -name "*.wav")
for i in $a
do
lame -h -b 192 "$i" "$/home/music/mp3/{i%.wav}.mp3"
done

The only problem is I have 8 gb of mp3s filed in a single folder called "mp3"

2.  the other option would be to copy the entire directory "wav" (space here is why I'm hesitant to do this - hard drive is limited, though I think I have barely enough room).  Run my original :

for i in *.wav; do     lame -h -b 192 "$i" "${i%.wav}.mp3";

then remove all the "wav" file (hopefully) from that directory and all subdirectories with:

find ~/Music -name "*.wav" -exec rm '{}' \;

so I retain the structure of this.  I'll post back if either of these work - but if there is an easier way to streamline option #2 but not having to copy the entire "wav" directory, I'm interested in hearing (this was my original question).


Avatar of Merete
Well I dont know how to do this programmatically, maybe your ready to try somethign else,
 lets be realistic here dont drop hundreds on,, I used Super Video which can also convert Audio to MP3.
Put the output container to mp3 top left panel, then set your bitrates if needed stereo etc drag and drop your folder of wavs on then check the save to directory and hit encode.
I make a lot of wavs in Audacity for background audio and found that Super supported dropping a lot of wavs on and it would convert it all one after the after
Here's a guide but scroll it back to the top
http://www.erightsoft.net/faqt.html#Q020
Download here
Download SUPER ©  setup file
http://www.erightsoft.com/S6Kg1.html
Cheers
ASKER CERTIFIED SOLUTION
Avatar of Matt330
Matt330
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial