[comp.sys.ibm.pc] Redirecting Batch files Another Solution

stevenj@umbc3.UMD.EDU (Steven Vore ) (05/20/87)

Here's another way to do it

contents of D.BAT follow, I put comments within it so you can cut
it out, use it, and still remember what it does years from now 
when you're looking back at this strange thing we used back in
'87 called MS-DOS.........
not a shell script or uuencoded or anything.. just plain ol' english!
----- cut here -------------------------
echo off
goto start
This batch file will either:
     a> display the directory (paged) to the console  or
     b> redirect the directory into a file
depending upon the condition (Z%1Z==ZZ).  This will test to
see if there is a parameter.  If there is (the condition shown
is false), control jumps to the label :param, from which the
directory is executed and redirected into a file with the same
name as the first parameter.  Any subsequent parameters are
ignored.  If there are no parameters, control jumps to the
label :noparam and the directory is displayed to the console
in the normal way.

:start
if Z%1Z==ZZ goto noparam
:param
echo :param
dir > %1
goto exit
:noparam
echo :noparam
dir /p
:exit
-------- cut here -----------------

Steven J. Vore
stevenj@umbc3.umd.edu