Difference between revisions of "REACT:Backup DATA Track"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
(Added category code)
(Code changes, more examples, etc.)
Line 1: Line 1:
 
Here's a method to backup all the files from an enhanced cd when ripping albums with REACT.
 
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.
  
  
Line 5: Line 9:
 
Brief explanation what the following code does:
 
Brief explanation what the following code does:
 
# Check from a cuefile if there's a data track present in the CD.
 
# Check from a cuefile if there's a data track present in the CD.
 +
# Test if CD is locked/not accessible and pause & stop backup on errors.
 
# Get CD label from DIR command.
 
# Get CD label from DIR command.
 
# Create a subdir '''DATA TRACK (''<CD label>'')'''.
 
# Create a subdir '''DATA TRACK (''<CD label>'')'''.
# Copy all files (+hidden and system files) with attributes from the CD drive including empty subdirs.
+
# Copy all files (+hidden and system files) with attributes from the CD drive including empty subdirs and verify the new files.
 
# Pause and print error message if there was an error in the copy process.
 
# Pause and print error message if there was an error in the copy process.
  
Line 18: Line 23:
  
 
Under [UserSettings]:
 
Under [UserSettings]:
<pre>CDDrive=E:</pre>
+
<pre>CDDrive=D:</pre>
 
Change the drive letter to match your cd ripping drive.
 
Change the drive letter to match your cd ripping drive.
  
  
Use the following code in your '''REACT-image.cfg''' or '''REACT-track.cfg''' file.
+
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.
 
<pre>
 
<pre>
 +
GOTO :EOF
 +
 +
:BackupDataTrack
 +
 
REM ** Copy all files from the CD if there's a data track.
 
REM ** Copy all files from the CD if there's a data track.
SET /A DataExists=0
+
SET DataExists=0
  
IF EXIST "@albumfile@.[mg].cue" (
+
IF NOT EXIST "@albumfile@.[mg].cue" GOTO :EOF
    SETLOCAL ENABLEDELAYEDEXPANSION
+
     FOR /F "tokens=* delims=" %%i IN ('FINDSTR /R "TRACK....MODE*" "@albumfile@.[mg].cue"') DO SET DataExists=1
     FOR /F "tokens=* delims=" %%i IN ('FINDSTR /R "TRACK....MODE*" "@albumfile@.[mg].cue"') DO SET /A DataExists=!DataExists! + 1
+
    SETLOCAL DISABLEDELAYEDEXPANSION
+
)
+
  
IF NOT %DataExists%==0 (
+
IF %DataExists%==0 GOTO :EOF
     ECHO ===== BACKING UP DATA FILES =====
+
     ECHO. &ECHO ===== BACKING UP DATA FILES ===== &ECHO.
 
      
 
      
     SETLOCAL ENABLEDELAYEDEXPANSION
+
     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
+
     REM ** Get CD label.
     FOR /F "tokens=5* delims= " %%a IN ('DIR @CDDrive@ ^| FIND /I "Volume in drive"') DO SET CDLabel=%%b
+
     FOR /F "tokens=5* delims= " %%a IN ('DIR @CDDrive@ ^| FIND /I "Volume in drive"') DO SET DataDir="DATA TRACK (%%b)"
 
      
 
      
     SET DataDir=DATA TRACK ^(!CDLabel!^)
+
     REM ** Make a subdir with CD label in parentheses.
     MKDIR "!DataDir!"
+
     MKDIR %DataDir%
 
      
 
      
     REM ** Copy all files (+hidden and system files) with attributes from the CD drive including empty subdirs
+
     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
+
     XCOPY @CDDrive@\*.* %DataDir% /E /H /K /V
 
      
 
      
     REM ** Pause on errors.
+
     REM ** Pause on XCOPY errors.
     IF ERRORLEVEL 1 ECHO. &ECHO ===== COPY FAILED ===== &ECHO. &PAUSE
+
     IF ERRORLEVEL 1 ECHO. &ECHO ===== ERROR: COPY FAILED ===== &ECHO. &PAUSE
 
      
 
      
     SETLOCAL DISABLEDELAYEDEXPANSION
+
     ECHO.
)
+
 
 +
GOTO :EOF
 
</pre>
 
</pre>
  
  
In example, you could put the above code between ''PUSHD'' and ''POPD'' lines in the post-processing section of the '''REACT-track.cfg''' file:
+
 
 +
Next you have to add the following code to the proper place in '''REACT-image.cfg''' and/or '''REACT-track.cfg''' file(s):
 +
<pre>
 +
REM ** Call data track detection and backup routine
 +
CALL :BackupDataTrack
 +
</pre>
 +
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):
 
<pre>
 
<pre>
 
IF @Flac@==1 (
 
IF @Flac@==1 (
 
     PUSHD %TrackDir_Flac%
 
     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
 
         IF %add_rg%==1 @tools@\Glob.exe -v -c @tools@\metaflac.exe %RG_MetaFlac% *.flac
 
         REM COPY /Y "@eaclog@" "EAClog.txt"
 
         REM COPY /Y "@eaclog@" "EAClog.txt"
 +
    POPD
 +
)
 +
</pre>
  
        <INSERT THE CODE HERE>
 
  
 +
Example 2. '''REACT-image.cfg''' (for Flac '''tracks'''):
 +
<pre>
 +
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
 
     POPD
)
+
:end_flac_tracks
 
</pre>
 
</pre>
  
  
 +
Example 3. '''REACT-image.cfg''' (for Flac '''images'''):
 +
<pre>
 +
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
 +
</pre>
 +
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.
  
This method has been tested to work at least in Windows XP.
+
If you have any comments, questions, bug reports, etc., please contact [http://www.hydrogenaudio.org/forums/index.php?showuser=48750 Akkurat] in Hydrogenaudio Forums.
  
  
 
[[Category:REACT|Backup DATA Track]]
 
[[Category:REACT|Backup DATA Track]]

Revision as of 22:50, 8 May 2008

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]:

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.