DIR2BAT - An Application Compiler

Do you collect web pages and wish you could turn each of them into a single file? Or be able to compress applications so they don't take up excessive disk space when not being used? DIR2BAT for Windows 95 uses the PKZIP utilities PKZIP.EXE, PKUNZIP.EXE and PKZIP25.EXE to compress entire directory branches with a designated run file into a single self-extracting batch. Both versions are needed, 2.04 because it will tolerate having the archive attached to the end of a batch file, and 2.50 to deal with Windows' long filenames.

For best results place DIR2BAT.BAT in a path directory.
To use, go to the directory you wish to compress and enter...

...where outfile.bat is the name of the batch to create, runfile.ext is the file to launch, and *.* represents the files to compress (all of them). You can also specify individual filenames or masks if you only want to compress specific files in the directories. Paths can also be specified for the output file and directory/files to compress, the path for the run file must be relative if specified.

An earlier version posted here used only PKZIP/UNZIP and was limited to 8.3 filenames and required a tricky batch to rename/edit the files if long filenames were present, and worse occasionally bugged out, unzipping the first file out of tempdir.zip instead of the tempdir.zip file. The PKZIP25 patches worked fine, only drawback is the need for both versions of PKZIP.

Here it is... (also in the utilbats.zip file)


:: DIR2BAT  (c)1998 Terry Newton  7/14/98
:: Requires PKZIP25.EXE, PKZIP.EXE and PKUNZIP.EXE
:: Designed for Windows 95
::
:: This batch "compiles" directories with subdirectories
:: into compressed self-extracting batch files that when
:: run temporarily decompress and run the specified file
:: using the Win95 start command. Particularly handy for
:: compressing web pages or "running" them from an archive,
:: can also be used to compress complete applications.
:: Decompresses to the current drive.
::
:: Usage: DIR2BAT batfile runfile filemask [filemask] ...
:: For example: DIR2BAT webpage.bat index.htm *.*
:: Batfile should end in .bat
::
@echo off
if .%3==. echo DIR2BAT batfile runfile filemask [filemask] ...
if .%3==. goto end
echo Compiling...
md \dir2bat$
:: zip up target files...
pkzip25>nul -add -dir \dir2bat$\tempdir.zip %3 %4 %5 %6 %7 %8 %9
pkzip>nul \dir2bat$\dir2bat.zip \dir2bat$\tempdir.zip
:: create a loader...
echo> \dir2bat$\dir2bat.t1 @echo off
echo>>\dir2bat$\dir2bat.t1 md \dir2bat$
echo>>\dir2bat$\dir2bat.t1 pkunzip %%0 \dir2bat$
echo>>\dir2bat$\dir2bat.t1 pkzip25 -ext -dir \dir2bat$\tempdir \dir2bat$
echo>>\dir2bat$\dir2bat.t1 del \dir2bat$\tempdir.zip
echo>>\dir2bat$\dir2bat.t1 cls
echo>>\dir2bat$\dir2bat.t1 echo.
echo>>\dir2bat$\dir2bat.t1 echo Launching %2
echo>>\dir2bat$\dir2bat.t1 echo Waiting for application to end...
echo>>\dir2bat$\dir2bat.t1 start /w \dir2bat$\%2
echo>>\dir2bat$\dir2bat.t1 deltree /y \dir2bat$
echo>>\dir2bat$\dir2bat.t1 cls
:: add an EOF char...
copy \dir2bat$\dir2bat.t1 \dir2bat$\dir2bat.t2 /a>nul
:: append loader and zip and copy to target in current...
copy/b \dir2bat$\dir2bat.t2+\dir2bat$\dir2bat.zip %1>nul
:: clean up...
deltree /y \dir2bat$>nul
:end