Re: Whats going on in this bat file?




"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxxxxxxx> wrote in message
news:ep%23IeJinHHA.5052@xxxxxxxxxxxxxxxxxxxxxxx


SEgerton wrote:
Hello,

Line bye line, can someone please tell me what is going on in this bat
file. I not sure what is going on in each step. I have a general
understanding of what the bat is doing, but have to test it on a
Windows2000/XP platform and want to completely understand it first. The
commands and variables. It is currently running on a Windows 98. The user
also runs this from a command prompt. This bat file is named C. This is
what what the user types at the command prompt. "c 05212007". The number
following c is a folder created prior to running this script.



@echo off
cls
=> clears the (dos console) screen
if "%1"=="" goto bad
=> if the (first) parameter is null, abort
if not exist g:\%1\*.* goto bad
=> if the parameter points to a non existant directory, abort
dir g:\%1\*.txt /on > c:\windows\temp\dir.xls
=> list the directory the parameter points to, result in dir.xls
although the directory will be a text file, not an excel file.

or perhaps: produce a listing of all .txt files in the directory in file
dir.xls, shown in alphabetical order.

g:
=> switch to drive g
cd\%1
=> make the working directory parameter one
echo Record Counts: > c:\windows\temp\records.txt
=> put a header text line in records.txt file
for %%1 in (*.txt) do find /i /c "ACCT#" %%1 >>
c:\windows\temp\records.txt
=> a loop which places a listing of the files named acct# in
records.txt

Actually, I think this will not only list all .txt files, but display the
number of lines they have containing the string "ACCT#", "acct#", or other
variations, the format will be something like this:

------------ cat.txt: 12
------------ dog.txt: 3

c:
=> switch to drive c
cd\windows\temp
=> go to the wintmp directory
"c:\program files\microsoft office\office\excel.exe" records.txt dir.xls
=> call excel with the two files, although I'm not sure what
excel will do with them -- probably display the data
on a spread***

I suspect that the original concept was to load these two files, and cut and
paste their contents in some manner into the formulas.xls spread***, which
would then produce a report of some sort on the file data collected. the
first two files need to be loaded by explicitly running excel because
otherwise the .txt file would open in notepad, and the .xls (being a .txt
file at heart) would probably generate some errors.

formula.xls
=> call excel, and run the formula spread***
goto end
=> exit the bat file
:bad
=> error trap.
echo You must enter a valid G drive directory format(MMDDYYYY) Example:
%0 01192006
=> post an error message to the console
:end


If this is not good enough, wait around for our resident dos bat
expert: Tom Lavedas.

I second that suggestion. Also note that because there are differences
between the various flavours of windows, the effect of the batch file may
not be identical on your xp/2000 system to what it was on 98.

/Al

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)




.


Loading