Solved How to batch encode mp3s from the command line and move

October 22, 2017 at 16:47:17
Specs: Windows 10
How to encode with lame and have output moved to new directory.
In Linux I can do this:
mkdir recoded 
for f in *.mp3; 
do lame -b 32 "$f" ./recoded/"${f%.mp3}.mp3"; 
done

So far in Windows 10 I have been able to run this from the directory that holds lame:
FOR %X IN (C:\Users\johnn\Desktop\test\\*.mp3) DO lame -b 32 %X

These are all recording of podcasts. Moving down to -b 32 does not affect my ability to listen to people talk, but it does significantly reduce the size of the files. When I run the above code I end up with file.mp3.mp3 in the same directory as the original file. What do I need to do to end up with file.mp3 in a sub-directory of the directory which contains the original files. In this case C:\Users\johnn\Desktop\test\recoded

Thank you and I hope my question was clear.


See More: How to batch encode mp3s from the command line and move

Reply ↓  Report •

#1
October 22, 2017 at 18:28:43
✔ Best Answer
Pretty sure the command line options don't change between LAME ports, so the more-or-less direct port of your shell script would be:
CD /D C:\Users\johnn\Desktop\test
MD Recoded
REM Just going to assume lame is in this "test" directory, or in your PATH
FOR %X IN (*.mp3) DO lame -b 32 "%X" ".\recoded\%~nX"

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
October 22, 2017 at 20:17:22
Thank you for your help. I truly appreciate it.
What does the /D do?

Yes lame is in path. When I type lame -v in the command line I get:


C:\Users\johnn>Lame -v
LAME 64bits version 3.99.5 (http://lame.sf.net)

usage: Lame [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

Try:
     "Lame --help"           for general usage information
 or:
     "Lame --preset help"    for information on suggested predefined settings
 or:
     "Lame --longhelp"
  or "Lame -?"              for a complete options list

Your script worked like a charm. I only had to add %~nX.mp3" or the encoded files lacked an extension. Thank you again!

message edited by GrouchyGaijin


Reply ↓  Report •

#3
October 22, 2017 at 21:22:00
Changes the current drive, if required. It's needed because DOS, which this is loosely emulating, has a current directory for each drive. Note that just about every CMD command has its own help, accessed by the /? switch.
cd /?
for /?
cmd /?

I thought lame was already adding .mp3 to the output, but if not, you can simplify the FOR down to:

FOR %X IN (*.mp3) DO lame -b 32 "%X" ".\recoded\%X"

How To Ask Questions The Smart Way

message edited by Razor2.3


Reply ↓  Report •
Related Solutions


Ask Question