I have ripped my CD collection into perfect quality .flac files and want to convert osme selections of music to AAC for my iPod. Is there a simple way to do this? What program should I use?
[a href="index.php?act=findpost&pid=239384"][{POST_SNAPBACK}][/a]
I have written a few batch scripts to convert all my flac files to m4a (aac), mp3, mpc, or ogg. Here are the steps and code to set it up.
Assumptions:
- All .flac files are in the same directory, not in subdirectories. (Example C:\music\song.flac)
- All .flac files are properly tagged.
1. In your .flac file directory (see example above) make a "convert" directory (ie. C:\music\convert).
2. In this "convert" directory, make an "aac", "mp3", and "flac" directory (ie. C:\music\convert\aac & C:\music\convert\flac).
3. Copy itunesencode.exe, faac.exe, naacenc.exe, and tg.exe into the "aac" directory (from www.rarewares.org)
4. Copy flac.exe and metaflac.exe into the "flac" directory.
Copy lame.exe into the "mp3" directory.
5. Create a file called "encode.cmd" in the "convert" directory.
6. Use notepad to open the file and copy and paste the code below into the file. Save.
encode.cmd
@ECHO OFF
rem :Check to see if path exists, if not create and encode.
if exist ..\%ext% (
echo.
) else (
mkdir ..\%ext%
)
rem :Grab the tag data from the .flac file and store it in temp.txt for now.
flac\metaflac --show-vc-field=artist %1 > temp.txt
flac\metaflac --show-vc-field=title %1 >> temp.txt
flac\metaflac --show-vc-field=album %1 >> temp.txt
flac\metaflac --show-vc-field=date %1 >> temp.txt
flac\metaflac --show-vc-field=tracknumber %1 >> temp.txt
flac\metaflac --show-vc-field=genre %1 >> temp.txt
rem :Turn the tags into var's for later use.
for /F "tokens=1,2 delims==" %%i in (temp.txt) do set %%i=%%j
rem :Now delete the temp file.
del temp.txt
rem :If the track number is 9 or less, lets add a 0 in front for formatting.
if %tracknumber%==1 set tracknumber=0%tracknumber%
if %tracknumber%==2 set tracknumber=0%tracknumber%
if %tracknumber%==3 set tracknumber=0%tracknumber%
if %tracknumber%==4 set tracknumber=0%tracknumber%
if %tracknumber%==5 set tracknumber=0%tracknumber%
if %tracknumber%==6 set tracknumber=0%tracknumber%
if %tracknumber%==7 set tracknumber=0%tracknumber%
if %tracknumber%==8 set tracknumber=0%tracknumber%
if %tracknumber%==9 set tracknumber=0%tracknumber%
rem :Check the file type and goto proper encoder.
if %ext% EQU mp3 goto MP3
if %ext% EQU mpc goto MPC
if %ext% EQU ogg goto OGG
if %ext% EQU aac goto AAC
if %ext% EQU m4a goto AAC
else echo Unknown Format: %ext%
pause
goto END
:MP3
rem :Encode and tag the new file.
if %program%==lame (
for %%I in (%1) do flac\flac -d -c %%I | mp3\lame - --preset extreme --id3v2-only --pad-id3v2 --ta "%artist%" --tt "%title%" --tl "%album%" --ty "%date%" --tn "%tracknumber%" --tg "%genre%" "..\%ext%\%%~nI.%ext%"
goto END
) else if %program%==itunes (
for %%I in (%1) do flac\flac -d %%I
for %%I in (%1) do aac\iTunesEncode -a "%artist%" -t "%title%" -l "%album%" -y "%date%" -n "%tracknumber%" -g "%genre%" -d -e "MP3 Encoder" -i "..\%%~nI.wav" -o "..\%ext%\%%~nI.%ext%"
for %%I in (%1) do del "..\%%~nI.wav"
goto END
) else (
echo Unknown Encoder: %program%
pause
goto END
)
:MPC
rem :Encode and tag the new file.
for %%I in (%1) do flac\flac -d -c %%I | mpc\mppenc --quality 6 --xlevel --artist "%artist%" --title "%title%" --album "%album%" --year "%date%" --track "%tracknumber%" --genre "%genre%" - "..\%ext%\%%~nI.%ext%"
goto END
:OGG
rem :Encode and tag the new file.
for %%I in (%1) do flac\flac -d -c %%I | ogg\oggenc -q 7 -a "%artist%" -t "%title%" -l "%album%" -d "%date%" -N "%tracknumber%" -G "%genre%" -o "..\%ext%\%%~nI.%ext%" -
goto END
:AAC
rem :Encode and tag the new file.
if %program%==nero (
for %%I in (%1) do flac\flac -d %%I
for %%I in (%1) do aac\naacenc -extreme -qh "..\%%~nI.wav" "..\%ext%\%%~nI.%ext%"
for %%I in (%1) do aac\tg "..\%ext%\%%~nI.%ext%" --artist "%artist%" --album "%album%" --track "%tracknumber%" --title "%title%" --genre "%genre%" --year "%date%"
for %%I in (%1) do del "..\%%~nI.wav"
goto END
) else if %program%==itunes (
for %%I in (%1) do flac\flac -d %%I
for %%I in (%1) do aac\iTunesEncode -a "%artist%" -t "%title%" -l "%album%" -y "%date%" -n "%tracknumber%" -g "%genre%" -d -e "AAC Encoder" -i "..\%%~nI.wav" -o "..\%ext%\%%~nI.%ext%"
for %%I in (%1) do del "..\%%~nI.wav"
goto END
) else if %program%==faac (
for %%I in (%1) do flac\flac -d -c %%I | aac\faac -q 150 -w --artist "%artist%" --title "%title%" --album "%album%" --year "%date%" --track "%tracknumber%" --genre "%genre%" -o "..\%ext%\%%~nI.%ext%" -
goto END
) else (
echo Unknown Encoder: %program%
pause
goto END
)
:END
rem :All done with the var's, lets purge.
set artist=
set title=
set album=
set date=
set tracknumber=
set genre=
7. Create a file called "flac-m4a.cmd" in the "covert" directory.
8. Use notepad to open the file and copy and paste the code below into the file. Save.
flac-m4a.cmd
@ECHO OFF
rem :What program do you want to use to encode?
rem :Choices are case sensitive: nero | itunes | faac
set program=nero
rem :Set the file extension and directory path.
set ext=m4a
for %%I in (..\*.flac) do encode.cmd "%%I"
rem :Purge the vars.
set ext=
set program=
for mp3 conversion
flac-mp3.cmd
@ECHO OFF
rem :What program do you want to use to encode?
rem :Choices are case sensitive: lame | itunes
set program=lame
rem :Set the file extension and directory path.
set ext=mp3
for %%I in (..\*.flac) do encode.cmd "%%I"
rem :Purge the vars.
set program=
set ext=
9. Now just double click on the flac-m4a.cmd file and the batch conversion will begin.
The directory structure should look like this:
C:\--
\Music\--
\convert\-----
Song1.flac |
Song2.flac |
Song3.flac |
\aac\-------- iTunesEncode.exe, faac.exe, naacenc.exe, tg.exe
\mp3\------- lame.exe
\flac\------- flac.exe, metaflac.exe
encode.cmd
flac-m4a.cmd
flac-mp3.cmd
If anyone would like the batch script code for mp3, ogg, or mpc just let me know. Once I get all the bugs worked out, I'll zip (or rar) it up and thought it out there for download somewhere.
Edit: Revised code and instructions to add use of iTunes encoder via iTunesEncode.exe
Edit: Revised code and instructions to add mp3 encoder