Squeebee
asked on
More Batch File Problems
This is on Xp if it is relevant and is a continuation of my previous question. This script hits the error catch even with a file of 3,283,729 bytes:
@echo off
echo\
echo Changing Directory
cd /d %2
del %TEMP\chmbuild\*
CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2
echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.langu age ja --stringparam htmlhelp.use.hhk 1 --output %TEMP%\chmbuild\ "%DOCBOOK_BASE%\xsl\htmlhe lp\mysql-h tml-help.x sl" "%TEMP%\chmbuild\%1.xml"
if not %errorlevel%==0 goto :ERROR
echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.h hp
if not %errorlevel%==0 goto :ERROR
echo Checking File Size
pushd.
cd /D "%TEMP%\chmbuild"
set error=
for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do if /I %%~za LSS 2000000 set error=Y
popd
if "%error%"=="Y" goto :ERROR
echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.c hm C:\built-docs\%1-%3.chm
if not %errorlevel%==0 goto :ERROR
goto :EXIT
:ERROR
echo ERROR ENCOUNTERED
exit /B -1
:EXIT
exit /B 0
@echo off
echo\
echo Changing Directory
cd /d %2
del %TEMP\chmbuild\*
CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2
echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.langu
if not %errorlevel%==0 goto :ERROR
echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.h
if not %errorlevel%==0 goto :ERROR
echo Checking File Size
pushd.
cd /D "%TEMP%\chmbuild"
set error=
for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do if /I %%~za LSS 2000000 set error=Y
popd
if "%error%"=="Y" goto :ERROR
echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.c
if not %errorlevel%==0 goto :ERROR
goto :EXIT
:ERROR
echo ERROR ENCOUNTERED
exit /B -1
:EXIT
exit /B 0
ASKER
I do not see the moving message. I've tried replacing the if with an echo to see what size is reported. Will let you know.
ASKER
This script results in no size value echoed at all.
@echo off
echo\
echo Changing Directory
cd /d %2
del %TEMP\chmbuild\*
CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2
echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.langu age ja --stringparam htmlhelp.use.hhk 1 --output %TEMP%\chmbuild\ "%DOCBOOK_BASE%\xsl\htmlhe lp\mysql-h tml-help.x sl" "%TEMP%\chmbuild\%1.xml"
if not %errorlevel%==0 goto :ERROR
echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.h hp
if not %errorlevel%==0 goto :ERROR
echo Checking File Size
pushd.
cd /D "%TEMP%\chmbuild"
set error=
for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do echo %%~za
popd
if "%error%"=="Y" goto :ERROR
echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.c hm C:\built-docs\%1-%3.chm
if not %errorlevel%==0 goto :ERROR
goto :EXIT
:ERROR
echo ERROR ENCOUNTERED
exit /B -1
:EXIT
exit /B 0
@echo off
echo\
echo Changing Directory
cd /d %2
del %TEMP\chmbuild\*
CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2
echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.langu
if not %errorlevel%==0 goto :ERROR
echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.h
if not %errorlevel%==0 goto :ERROR
echo Checking File Size
pushd.
cd /D "%TEMP%\chmbuild"
set error=
for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do echo %%~za
popd
if "%error%"=="Y" goto :ERROR
echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.c
if not %errorlevel%==0 goto :ERROR
goto :EXIT
:ERROR
echo ERROR ENCOUNTERED
exit /B -1
:EXIT
exit /B 0
ASKER
And yet I get ERROR ENCOUNTERED:
Created c:\DOCUME~1\XPBox\LOCALS~1 \Temp\chmb uild\htmlh elp.chm, 3,283,731 bytes
Compression decreased file by 8,088,571 bytes.
ERROR ENCOUNTERED
Building 5.0 CHM ...
Created c:\DOCUME~1\XPBox\LOCALS~1
Compression decreased file by 8,088,571 bytes.
ERROR ENCOUNTERED
Building 5.0 CHM ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found it, it was the errorlevel check after the call to hhc.exe. The foolish thing returns 1 upon a successful compile instead of 0. I want to beat someone.
I ran a test of this code that simulates the file size error processing in your code:
@echo off
set error=
for /f "delims=" %%a in ('dir /b "%~1"') do echo if /I %%~za LSS 2000000 set error=Y
for /f "delims=" %%a in ('dir /b "%~1"') do if /I %%~za LSS 2000000 set error=Y
if "%error%"=="Y" echo Error
I ran it against some huge database backup files and it didn't report an error:
05/03/2006 02:52 PM 828,255,744 PMC_20060502_NOREPL.bak
Can you run the test against the file you have the problem with? The batch file accepts the file name and you should run it from the directory where the file exists (cd /D "%TEMP%\chmbuild").
My reference to the "other" error processing deals with the move code:
echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.c
if not %errorlevel%==0 goto :ERROR
Could that be failing? You'd see the "Moving from Temp Directory" message.