Batch file examples

Display all GIF files in an HTML page

The set of batch files presented here are meant to create an HTML file referencing all *.GIF files in the current directory.
I created these batch files for my son, to view his collection of animated GIFs.

The general idea is that one batch file - __GIF.BAT - calls a second batch file - ___GIF.BAT - once for each GIF it finds.
This second batch file will display the GIF in an <IMG> tag.
A third batch file - _GIF.BAT - is needed to call the first one, providing enough environment space and redirecting the output to an HTML file _GIF.HTM.

Usage:

change the directory to the one containing your GIF files

execute _GIF.BAT

open the resulting _GIF.HTM in your browser to view all GIF files

This batch file has been tested in Windows 98 and in OS/2 Warp 4.
The only "problem" left to be solved is the empty <IMG> tag that is created at the end of _GIF.HTM.

@ECHO OFF
REM __GIF.BAT
REM Save current PROMPT
SET OLDPRM=%PROMPT%
REM Set PROMPT to display starting HTML tags
PROMPT $LHTML$G$_$LBODY$G$_$_$LIMG="
REM Set ECHO on, insert 1 empty line and then set
REM ECHO off again to actually display the prompt
ECHO ON
@ECHO OFF
REM Set PROMPT to display HTML IMG tags
PROMPT "$G$_$LIMG src="
REM Call secondary batch file ___GIF.BAT
REM for each GIF in the current directory
FOR %%A IN (*.GIF) DO CALL ___GIF %%A
REM Set PROMPT to display closing HTML tags
PROMPT "$G$_$L/HTML$G$_$L/BODY$G
REM Set ECHO on, insert 1 empty line and then set
REM ECHO off again to actually display the prompt
ECHO ON
@ECHO OFF
REM Restore original PROMPT
PROMPT %OLDPRM%

The PROMPT can be set using either PROMPT string or SET PROMPT=string
Use the first method if you need to include "=" characters in string, or replace "=" with "$Q" if you insist on using the second method.

Update

Display GIF & JPG files in an HTML page

The batch file PICTURES.BAT and its helper batch files PICTURE2.BAT and PICTURE3.BAT will do the same things _GIF.BAT does, but for both GIF and JPG files.
It will create an HTML file PICTURES.HTM.
Recently an NT version has been added: Pict_NT.bat, which consists of one single batch file.