@Echo Off

rem      This file will check the status of the Armenu.onl
rem      file during the startup of the Artist 3
rem      computer.  If it is a "bad" size, then it will
rem      copy it from backup.


rem     first argument is the location of the backup file
rem     second argument is the log file

Echo .
Echo Begin Testing Armenu.onl
Echo Location of backup file: %1
Echo Logfile: %2

Echo Artist3 Log Entry >> %2

Rem Date /T >> %2
REM 26 Feb 2007. RH.
REM  Note that the following method of displaying the date
REM and time is NOT pretty, but it works.
VER | DATE > TEMP.BAT
ECHO SET DATE=%%4>CURRENT.BAT
CALL TEMP.BAT
ECHO %DATE% >> %2
VER | TIME > TEMP.BAT
ECHO SET TIME=%%3>CURRENT.BAT
CALL TEMP.BAT
ECHO %TIME% >> %2
REM CLEAN UP
DEL TEMP.BAT
DEL CURRENT.BAT

Echo Check Armenu.onl size >> %2
REM I don't know where the line below came from, but I'm
REM commenting it out. 26 Feb 2007.  RH.
REM Echo Logged Date

rem     Place the size of Armenu.onl within Armenusz.txt
dir /-C Armenu.onl > Armenusz.txt
Echo Created Armenusz.txt

rem     This will properly test Armenu.onl, regardless of file case combinations
rem     and return the size of the file in bytes
gawk " /[Aa][Rr][Mm][Ee][Nn][Uu]/ { print $3 } " Armenusz.txt > temp.txt
REM 26 Feb 2007.  RH.
REM I'm deleting Armenusz.txt
del Armenusz.txt
Echo Run Gawk

rem     This sets up the environmental variable FILE_SIZE
copy init.txt+temp.txt varset.bat
call varset.bat
REM 26 Feb 2007.  RH.
REM I'm deleting varset.bat
del varset.bat
Echo Set up environmental variable

Echo Armenu size is %FILE_SIZE%

IF NOT EXIST Armenu.onl Goto copy_armenu

Echo Begin Conditional Statement
rem IF %FILE_SIZE% LEQ %2 Goto copy_armenu
IF %FILE_SIZE%==0 Goto copy_armenu
Echo Armenu.onl is greater than 0 bytes.  Do not restore from backup.
Echo Armenu.onl is greater than 0 bytes.  Do not restore from backup. >> %2
Goto end

:copy_armenu
Echo Armenu.onl is 0 bytes, copy %1 Armenu.onl
Echo Armenu.onl is 0 bytes, copy %1 Armenu.onl >> %2
COPY %1 Armenu.onl

:end
