Re: Whats going on in this bat file?





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.
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
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***
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.

cheers, jw
____________________________________________________________

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


.


Loading