REACT:Backup DATA Track

From Hydrogenaudio Knowledgebase

Here's a method to backup all the files from an enhanced cd when ripping albums with REACT.


Note that EAC sometimes "locks" the CD drive in a way that it's impossible to access the CD in Windows Explorer or DOS and thus this method of backing up the data track will fail. This method will detect such a situation and will pause the encoding process with an error message. This hindrance can be avoided by inserting the CD before starting REACT.


Brief explanation what the following code does:

  1. Check from a cuefile if there's a data track present in the CD.
  2. Test if CD is locked/not accessible and pause & stop backup on errors.
  3. Get CD label from DIR command.
  4. Create a subdir DATA TRACK (<CD label>).
  5. Copy all files (+hidden and system files) with attributes from the CD drive including empty subdirs and verify the new files.
  6. Pause and print error message if there was an error in the copy process.


Edit your REACT.ini file and make sure that the following two lines are set correctly.

Under [Settings]:

When using Akkurat's Mod 2.0.akku.b03 or higher version

CreateCuesheet=mg

otherwise use this setting

CreateAllCuesheets=1


Under [UserSettings]:

CDDrive=D:

Change the drive letter to match your cd ripping drive.


Copy the following code to the end of the REACT-image.cfg and/or REACT-track.cfg file(s) depending on which ripping methods you are using.

GOTO :EOF

:BackupDataTrack

REM ** Copy all files from the CD if there's a data track.
SET DataExists=0

IF NOT EXIST "@albumfile@.[mg].cue" GOTO :EOF
    FOR /F "tokens=* delims=" %%i IN ('FINDSTR /R "TRACK....MODE*" "@albumfile@.[mg].cue"') DO SET DataExists=1

IF %DataExists%==0 GOTO :EOF
    ECHO. &ECHO ===== BACKING UP DATA FILES ===== &ECHO.
    
    REM ** Test if CD is locked/not accessible and pause & stop backup on errors.
    DIR @CDDrive@ >NUL
    IF ERRORLEVEL 1 ECHO. &ECHO ===== ERROR: CD LOCKED/NOT ACCESSIBLE ===== &ECHO. &PAUSE &GOTO :EOF
    
    REM ** Get CD label.
    FOR /F "tokens=5* delims= " %%a IN ('DIR @CDDrive@ ^| FIND /I "Volume in drive"') DO SET DataDir="DATA TRACK (%%b)"
    
    REM ** Make a subdir with CD label in parentheses.
    MKDIR %DataDir%
    
    REM ** Copy all files (+hidden and system files) with attributes from the CD drive including empty subdirs and verify the new files.
    XCOPY @CDDrive@\*.* %DataDir% /E /H /K /V
    
    REM ** Pause on XCOPY errors.
    IF ERRORLEVEL 1 ECHO. &ECHO ===== ERROR: COPY FAILED ===== &ECHO. &PAUSE
    
    ECHO.

GOTO :EOF


Next you have to add the following code to the proper place in REACT-image.cfg and/or REACT-track.cfg file(s):

REM ** Call data track detection and backup routine
CALL :BackupDataTrack

NOTE! This code must be placed between PUSHD <destination directory> and POPD lines! See the examples below for more information.


Example 1. REACT-track.cfg (for Flac tracks, in post-processing section of the file):

IF @Flac@==1 (
    PUSHD %TrackDir_Flac%
        
        REM ** Call data track detection and backup routine
        CALL :BackupDataTrack
        
        IF %add_rg%==1 @tools@\Glob.exe -v -c @tools@\metaflac.exe %RG_MetaFlac% *.flac
        REM COPY /Y "@eaclog@" "EAClog.txt"
    POPD
)


Example 2. REACT-image.cfg (for Flac tracks):

IF NOT @Flac@==1 GOTO end_flac_tracks
    SET dest="@TrackDir_Flac@%trackDir%"
    IF NOT EXIST %dest% MKDIR %dest%
    PUSHD %dest%
        
        REM ** Call data track detection and backup routine
        CALL :BackupDataTrack
        
        IF @various@==1 SET VA_tag=-T $qalbum artist=@VA@$q
        IF %embed_cover%==1 SET Cover_tag=--picture=$#x
        @tools@\acdir.exe --overwrite --output "%TrackName%.flac" --extra-opt "|image/jpeg|||@cover@" --pipe "TITLE $n/$N flac $#T & @tools@\flac.exe @Opt_Flac@ %Cover_tag% %VA_tag% %Disc_Flac_acdir% -T artist=$#a -T album=$#T -T title=$#t -T tracknumber=$n/$N -T date=$q@year@$q -T genre=$q@genre@$q -T comment=$q@comment@$q -T encoded-by=$q%USERNAME%$q -T encoding=$qFlac @Ver_Flac@ @Opt_Flac@$q - -o $#o" "@sourcecuesheet@"
        IF %add_rg%==1 @tools@\Glob.exe -v -c @tools@\metaflac.exe %RG_MetaFlac% *.flac
        COPY /Y "@eaclog@" "EAClog.txt"
        IF %have_cover%==1 COPY /Y "@cover@" "folder.jpg"
        IF EXIST "@albumfile@.[*].cue" COPY /Y "@albumfile@.[*].cue" .
    POPD
:end_flac_tracks


Example 3. REACT-image.cfg (for Flac images):

IF NOT @ImageExt@==flac GOTO end_flac_image
    SET dest="@ImageDir_Flac@%imageDir%"
    IF NOT EXIST %dest% MKDIR %dest%
    
    REM ** Call data track detection and backup routine
    PUSHD %dest%
        CALL :BackupDataTrack
    POPD
    
    IF %embed_cover%==1 SET Cover_tag=--picture="|image/jpeg|||@cover@"
    @tools@\flac.exe @Opt_Flac@ %RG_Flac% %Cover_tag% %Disc_Flac% -T "%ArtistField%=@cdartist@" -T album="@album@" -T totaltracks="@numtracks@" -T date="@year@" -T genre="@genre@" -T comment="@comment@" -T encoded-by="%USERNAME%" -T encoding="Flac @Ver_Flac@ @Opt_Flac@" --tag-from-file="cuesheet=@cuesheet@" --tag-from-file="eaclog=@eaclog@" "@source@" -o "@image@"
    MOVE /Y "@image@" %dest%
    MOVE /Y "@cuesheet@" %dest%
    IF %have_cover%==1 COPY /Y "@cover@" %dest%\"@basename@.jpg"
:end_flac_image

Note that here we had to add PUSHD %dest% and POPD lines so that the data track files are copied to the right directory.



This method has been tested to work at least in English Windows XP.

If you have any comments, questions, bug reports, etc., please contact Akkurat in Hydrogenaudio Forums.