CD Backup

Using EAC, MAC, TAG and PAR2 To Back-Up a CD

Please note: this guide has been superceded by version 2.

This guide explains the steps necessary to:

The guide uses batch files to perform the above processes automatically.

What You Need

To implement this guide you will need the following:

So far I have only tested this on two PCs running Windows 2000. My batch files won't work on Windows 98 or below, I believe, as older versions of Windows use COMMAND.COM instead of CMD.EXE. I can only assume that they will on NT and XP. Please let me know if you know they do. Update: Treefingers has confirmed that this works fine on XP - many thanks to him. These are the most complicated batch files I have written, yet they are far from complicated (after seeing some of the examples I referenced), so I'm sure most of you could adapt them to your needs.

If you are eager to get going, here's some direct links, but be warned: these links will become obsolete - it is always best to go to the website and get the latest version.

Exact Audio Copy (1,720KB)   Monkey's Audio (2,719KB)   Tag (193KB)   par2cmdline (127KB)   The batch files (2KB)

Get The Applications and Batch Files Set Up

If you don't already have them download all the necessary applications, and my batch files (2KB).

As Monkey's Audio is an installer I let it install to the default path, "C:\Program Files\Monkey's Audio". Similarly, Exact Audio Copy is located in "C:\Program Files\Exact Audio Copy". All the other files (TAG.EXE, PAR2.EXE, eac-enc.bat and eac-post.bat) are in my folder "C:\DOS". I have added the path to this folder to the system variable "PATH", which means that I can run them from the command prompt from any folder without having to fully qualify the path. This isn't necessary for this guide, as the batch file uses the full path, for portability.

Amending the Batch File "eac-enc.bat"

This file stores the paths to MAC.EXE, TAG.EXE and PAR2.EXE, so, unless the paths to these applications are the same as mine, you will need to amend the following three lines, found near the top:

REM =======================================================
REM  PLEASE EDIT THE PATHS TO THE NECESSARY APPLICATIONS  
REM =======================================================
SET pathToMac="C:\Program Files\Monkey's Audio\MAC.EXE"
SET pathToTag="C:\DOS\TAG.EXE"
SET pathToPar2="C:\DOS\PAR2.EXE"
REM =======================================================

A batch file is just a plain text file, so you can open it in Notepad, or a text editor of your choice (EditPlus is mine). Change the paths to MAC.EXE, TAG.EXE and PAR2.EXE to match the correct paths for your PC, and save.

Exact Audio Copy

If you have never used Exact Audio Copy before I would suggest you first take some time to familiarise yourself with it. Setting up Exact Audio Copy is out of the scope of this document. I would suggest taking a look at the links page on the Exact Audio Copy website.

Update: I couldn't find this again at the time of writing, but there are some excellent tutorials at The Coaster Factory.

Once you are familiar with Exact Audio Copy you are ready to begin.

Creating a New Compression Profile

I would suggest that you create a new Compression Profile for this process. Exact Audio Copy has an excellent profiling setup where you can save a complete profile (all program settings), or just a profile of one option group - in this case, Compression.

At the bottom of the main Exact Audio Copy window you should see your profile selector, as below.

Profile selector

You will see from the screenshot that I currently have my "CMD" compression profile selected. To create a new profile:

You have now created a copy of your previous compression profile. We will change the compression settings and then save the profile. You can create numerous compression profiles (e.g.: create one for MP3 encoding) and use the dropdown list and "Load" button to switch between them.

Setting the Compression Options

From the menu select EAC > Compression Options... (or press F11). You will be presented with a dialogue as below.

This screenshot shows the dialogue correctly setup (for my PC at least) for this guide.

EAC's Compression options dialogue

As per above, please do the following:

  1. Check "Use external program for compression"
  2. Select "User Defined Encoder" from the dropdown list
  3. Enter ".ape" for the required file extension
  4. Use the "Browse..." button to locate CMD.EXE in the system32 folder. This may vary for NT or XP
  5. Enter the additional command line options exactly as shown, with one exception. Change the path to the batch file (C:\dos\eac-enc.bat) to match your setup. If your path contains spaces you must delimit the path with double quotes ( " ), e.g.: /c "C:\Batch Files\eac-enc.bat" %o %s %d "%a" "%g"
  6. Check "Delete WAV after compression"

Copy & Paste The Command Line Options

/c C:\dos\eac-enc.bat %o  %s  %d  "%a"  "%g"

Once you have setup the dialogue as above, amending the path to the batch file if required, click OK. From the main Exact Audio Copy window save your new compression profile by clicking the Save button.

Begin The Encoding

From the menu select Action > Copy Image & Create CUE Sheet > Compressed...

From the dialogue select where you would like to save your files. If you wish, change the name of the file from the default of "CDImage" - perhaps to the album name. Personally I intend to leave it as "CDImage", and file all backups in nested folders, with Albums nested within an Artist folder (e.g.: "F:\Pixies\Doolittle"). Your call.

Once you click Save on the file dialogue the process will begin.

The process is as follows:

  1. Exact Audio Copy will rip the CD to a WAV file in the folder you specified, with the name you specified, e.g.: "CDImage.wav". This process will be represented by an Exact Audio Copy dialogue showing the progress of the rip
  2. Once the WAV file has been created it will be renamed to a temporary value
  3. Exact Audio Copy will call CMD.EXE, which will run the batch file eac-enc.bat
  4. eac-enc.bat will load into a shell, list all relevant variables, and then run MAC.EXE to begin encoding the WAV to APE
  5. Once the file has been encoded eac-enc.bat will open a new shell which will run eac-post.bat
  6. eac-enc.bat will close
  7. Exact Audio Copy, thinking the process to be over (it knows nothing of eac-post.bat), will display a completion dialogue and rename the APE file to the name you specified, e.g.: "CDImage.ape"
  8. eac-post.bat will list all relevant variables, and wait for the APE file to be renamed. This wait should be unnoticeable, but the batch file must check in case the renaming has taken longer than the time it took the new shell to open
  9. eac-post.bat will run TAG.EXE to load the cuesheet generated by Exact Audio Copy, and set it to the APE file's APEv2 CUESHEET tag. It will also set the Artist and Album tags, using information passed from Exact Audio Copy (the parameters "%a" and "%g")
  10. eac-post.bat will run PAR2.EXE to create the PAR2 parity files
  11. eac-post.bat will close

View the example outputs for both eac-enc.bat and eac-post.bat.

Check the Results

You will now have three separate types of file in your folder:

  1. The cuesheet ("CDImage.ape.cue")
  2. The APE file ("CDImage.ape")
  3. Various PAR2 files ("CDImage.ape.par2", etc.)

You can delete the cuesheet, as its contents have been stored in the APE file. It would be very easy for eac-post.bat to do this, as a final process before exiting. It currently doesn't, just in case you want to keep the cuesheet for another purpose.

Other Relevant EAC Settings

Storing CD-Text Information in the Cuesheet

To store artist, album and track information in the cuesheet you will need to select EAC > EAC Options... from the menu (or press F9), select the "Tools" tab, and make sure the checkbox "Use CD-Text information in CUE sheet generation" is selected.

Creating a Log File Automatically

Exact Audio Copy will give you the opportunity to save the results to a log file at the end of the process, but you can specify that you want a log file created automatically. To achieve this, you will need to select EAC > EAC Options... from the menu (or press F9), select the "Tools" tab, and make sure the checkbox "Automatically write status report after extraction" is selected.

Possible Improvements and Amendments

Delete the Cuesheet

To automatically delete the cuesheet add the following lines to eac-post.bat, just before the line GOTO:EOF (I would put it right before, to ensure that Tag has already used it).

REM Delete cuesheet file
DEL "%~dp3%~n1%~x3.cue"

Don't Add Artist and Album Tags

If you are not using freedb.org to get album information you may not want to tag your APE files with "Unknown Artist" and "Unknown Album". To add the cuesheet only change the Tag line in eac-post.bat from:

%pathToTag% --ape2 --artist %4 --album %5 -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

... to:

%pathToTag% --ape2 -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

Update: I have now downloaded the whole freedb database. I downloaded the database in RAR format, at around 240MB. The database expanded to take up approximately 1.3GB of my hardrive. However, this does mean that I do not need to be connected to the Internet while I backup my CDs, which is great for me as I am still using a 56K modem. If you have broadband, and have a permanent connection to the Internet, then there is no point in you doing this. The database is about one month out of date at the moment, but it seems they do post updates monthly, so I should be due one soon. Most of my CDs are a few years old anyway...

Change the Compression Settings Manually, or Using Exact Audio Copy's Interface

Using the default batch files you will compress the WAV using Monkey's Audio's "Extra High" setting.

Change the Compression Manually

If you don't want to compress at Extra High you could change the following line in eac-enc.bat:

%pathToMac% %2 %3 -C4000

... to:

%pathToMac% %2 %3 -CXXXX

Where XXXX is one of the following values:

XXXX Compression
1000 Fast
2000 Normal
3000 High
4000 Extra High
5000 Insane (not recommended unless you are immortal)

Switch Between Normal and Extra High Using EAC

You will see from the Compression Options screenshot that there is a "High quality" and "Low quality" radio button on the Compression Options dialogue. We could use these to tell the batch file to encode at either Normal or Extra High compression (or Low and High, etc.).

To do this we need to change the command line options on the Compression Options dialogue (don't forget to save the profile after) to:

/c C:\dos\eac-enc.bat %o %s %d "%a" "%g" %hHIGH%h

... and change the following line in eac-enc.bat:

%pathToMac% %2 %3 -C4000

... to:

SET macCompression=2000
IF "%6"=="HIGH" SET macCompression=4000
%pathToMac% %2 %3 -C%macCompression%

If you want to encode With Extra High compression select "High quality", and if you want to use Normal compression select "Low quality". EPLS. Another idea here.

NB: I have implemented this one myself now, on the simple premise: why not?

Add the Album Genre as a Tag

To do this we need to change the command line options on the Compression Options dialogue (don't forget to save the profile after) to:

/c C:\dos\eac-enc.bat %o %s %d "%a" "%g" "%m"

You will need to change the following line in eac-enc.bat:

START CMD.EXE /c eac-post.bat %1 %2 %3 %4 %5

... to:

START CMD.EXE /c eac-post.bat %1 %2 %3 %4 %5 %6

... and change the Tag line in eac-post.bat from:

%pathToTag% --ape2 --artist %4 --album %5 -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

... to:

%pathToTag% --ape2 --artist %4 --album %5 --genre %6 -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

Add The EAC Log File As a Comment Tag

The real problem here is that the log is not created until Exact Audio Copy's completion dialogue is closed (the APE file is renamed when the dialogue opens, i.e.: when eac-enc.bat closes). Closing the dialogue is a manual process, and would interrupt the automated setup I prefer. It will also have to be done before PAR2 executes, and PAR2 takes a wee while - therefore you would be interrupting the process mid-flow.

If this was acceptable you could simply change the Tag line in eac-post.bat from:

%pathToTag% --ape2 --artist %4 --album %5 -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

... to:

ECHO.
ECHO Please close EAC's completion dialogue, then press any key to resume
PAUSE >NUL

REM Get log file name from album name, replacing illegal characters with a space (as per EAC)
CALL :MakePath "%~5.log" logFilename

REM Ensure EAC log file has been created
:LogFileCheck
IF NOT EXIST "%~dp3%logFilename%" GOTO WaitForLogFile
ECHO.
ECHO "%~dp3%logFilename%" exists.

%pathToTag% --ape2 --artist %4 --album %5 -f "COMMENT=%~dp3%logFilename%" -f "CUESHEET=%~dp3%~n1%~x3.cue" "%~dp3%~n1%~x3"

... and append the following to the very end of the file eac-post.bat

:WaitForLogFile
REM: Pause for two seconds before returning
ECHO.
ECHO Waiting for EAC log file, "%~dp3%logFilename%", to be created...
PING 1.1.1.1 -n 1 -w 2000 >NUL
GOTO LogFileCheck

:MakePath
SET tmpString=%1
SET tmpString=%tmpString:/= %
SET tmpString=%tmpString:\= %
SET tmpString=%tmpString::= %
SET tmpString=%tmpString:?= %
SET tmpString=%tmpString:<= %
SET tmpString=%tmpString:>= %
SET tmpString=%tmpString:|= %
REM Now remove asterisks...
SET tmpString=%tmpString: =/%
SET tmpString=%tmpString:,=\%
SET tmpString=%tmpString:&=¬%
SET tmpString=%tmpString:"=%
SET output=
SET /A counter=-1
:MakePathNextChar
SET /A counter+=1
CALL :EXEC SET char=%%tmpString:~%counter%,1%%%
if NOT DEFINED char GOTO :MakePathDone
if [%char%] EQU [*] SET char=/
SET output=%output%%char%
GOTO :MakePathNextChar
:MakePathDone
SET output=%output:/= %
SET output=%output:\=,%
SET %2=%output:¬=^&%
GOTO:EOF
:EXEC
%*
GOTO:EOF

This would pause the post-processing batch file until you manually closed Exact Audio Copy's completion dialogue, and then resumed the batch file by pressing any key. As with the APE file, the batch file will also wait, if necessary, until the log file is present. With this in mind, in reality you could always restart the batch file before closing the dialogue, as the batch file will just sit there waiting for the log file to become available.

NB: You will also need to select EAC > EAC Options... from the menu (or press F9), select the "Tools" tab, and make sure the checkbox "Automatically write status report after extraction" is selected.

Ditch The Monkey

Obviously this process will work for many other compression codecs. Maybe some time I'll post batch files that perform the same process with other codecs, like FLAC, OptimFrog, La or WavPack. If you adapt the batch files to this end perhaps you could send them to me, and I may post them here. Another idea here.

Rename Secondary Files

If you adapt this guide to use OptimFrog or WavPack you may choose to use DualStream or hybrid mode. If so, Exact Audio Copy will not rename the secondary files (OFC or WVC) once eac-enc.bat has completed, as it only knows of the primary file (OFS or WV).

To rename any files that are named "<temp>.<ext>" (e.g.: "<temp>.ofc") use one of the following code snippets - in either eac-enc.bat or eac-post.bat, depending on your requirements.

REM Rename temporary OFC file (tmp.ofc)
REN "%~dpn3.ofc" "%~n1.ofc"

... or

REM Rename all temporary files (tmp.*)
REN "%~dpn3.*" "%~n1.*"

The most likely implementation, using WavPack as an example, would be the following in eac-enc.bat:

REM ====================================
REM  Encode wave file using WAVPACK.EXE
REM ====================================
%pathToWavPack% -hb320x -c %2 %3
REM Rename correction file (tmp.wvc)
REN "%~dpn3.wvc" "%~n1.wvc"

Update: If You are using WavPack hybrid it is probably worth looking at this forum post from the developer David Bryant.

Other Improvements?

If you have any improvements or amendments to the batch files please let me know and I may add them here.

A few suggestions:

Testing

While trying to achieve my goal of automating this process I spent some time testing MAREO, and then a little more honing these batch files (2KB).

In order to stop each testing phase taking an age I used the following technique, which is neither revolutionary or complex, but I thought I would share none the less.

Create a Small Audio CD

To achieve this I used Nero. I opened a new session for an Audio CD, dragged a couple of MP3s into the pot, and then recorded to the Image Drive, creating a Nero image (NRG file) 66MB in size. I guess you could also make an image of a CD single, using your favourite CD copier (Clone CD version 4.2.0.2 for me).

Mount to a Virtual CD Drive

I have two virtual drives - one uses Clone CD's Virtual CloneDrive, the other Alcohol 120%'s Virtual Drive. However there is a free alternative, that gets a lot of good press, that being Daemon Tools. Whatever your virtual CD-ROM of choice, mount the Nero image to your virtual drive, and then use that "CD" in Exact Audio Copy. Exact Audio Copy can read virtual images very fast, and our CD is very short, so the ripping process is lightening. This lets you quickly get into the processing phase - spending more time testing your setup, and less time watching progress bars.

Update: I see you can now download CloneCD's Virtual CloneDrive for free. However, I have now tested, and am currently using, Daemon Tools. This would be my recommendation, as it can mount different image formats and will remount the image automatically at startup, unlike Virtual CloneDrive (or at least the version I was using).

The History

A short time ago I decided to backup my CD collection. I have maintained an extensive collection of MP3s for a few years, and have recently begun to think about a better backup approach.

I was originally simply considering LAME 192Kbps VBR MP3. However, I started hanging around the Hydrogen Audio forums, and soon realised that I needed to go with lossless compression. I had played around with Monkey's Audio over a year ago, but never did anything worthwhile with it. I read the threads and tested out a few other codecs, including FLAC, OptimFrog, La and WavPack.

There is lots of discussion about which lossless codec is best. On the assumption that they do all work as expected (i.e.: can encode and decode without loss of quality) it seems to me that it mainly comes down to what you are using the files for. FLAC has been optimised to decode very quickly, so is good for everyday use - but it's files are slightly bigger than Monkey's Audio or La. La seems to get very good compression results - but is slow, and processor hungry, to decode. I opted for Monkey's Audio for these reasons:

There's little point in me going into the whole story in detail again, and you've probably stopped reading this by now anyway, but for the full history behind this development please read this forum thread at Hydrogen Audio. Sufficing to say I've had to put in a little work (Tag, Batch Files) to get the set up I wanted. I think it was Mark Twain who once said, "No pain, no gain". Or was it BA Baracus?

Document Version History

Version Date Comment
1.9 2004-10-18 Removed hardcoded reference to C:\DOS\eac-post.bat from eac-enc.bat. Now correctly uses %~dp0eac-post.bat.
1.8 2004-09-10 Improved example code in section Add The EAC Log File As a Comment Tag.
1.7 2004-09-07 A few very minor amends and updates.
1.6 2004-09-05 Changed example code in section Add The EAC Log File As a Comment Tag to replace illegal characters. Thanks to aSceT for the feedback. Added example outputs for batch files.
1.5 2004-09-02 Added section Rename Secondary Files.
1.4 2004-09-01 Basic, minor, formatting changes.
1.3 2004-08-30 Amended the description of the encoding process, to be more accurate. Other minor text changes. Added section Other Relevant EAC Settings. Added section Add the Album Genre as a Tag. Minor update to batch files - changed relevant examples to reflect this.
1.2 2004-08-27 Added the Testing section.
1.1 2004-08-27 Minor improvements to explanation text in one or two places. Added some suggestions to Other Improvements. Added print stylesheet for improved printing. Added link to The Coaster Factory.
1.0 2004-08-26 Initial version.

 

Jump: Top | What You Need | Get The Applications and Batch Files Set Up | Exact Audio Copy | Possible Improvements and Amendments | Testing | The History


Home | Tag | Wapet | CD Backup | Email Me


This document has been printed from http://synthetic-soul.mysite.wanadoo-members.co.uk/