SET DataEntry=???%COMPUTERNAME%???
SET DataEntry=%DataEntry%,???%USERNAME%???
SET DataEntry=%DataEntry%,???%DATE%???
SET DataEntry=%DataEntry%,???%TIME%???
REM Locate all of the temporary files on your hard drive.
@ECHO Locating temporary files to delete.
156 CHAPTER 5 CREATING CMD AND BAT FILES
FOR /F %%F IN (DelFiles.TXT) DO CALL :AddValue %%F
GOTO :Finished
REM Work with the individual directory entries as a set
REM and process them as part of a FOR command.
:AddValue
@ECHO Adding database values for %1.
FOR /F "delims==??? %%E IN ('Dir %1 /B /S??™) DO @ECHO %DataEntry%,???%%E??? >> Output.CSV
GOTO :EOF
:Finished
@ECHO ON
The idea behind CSV is that you encapsulate the individual data values in quotes and separate
them with commas. This example works as most batch files that create CSV will work. You begin
by creating one or more static data values that provide a snapshot of this particular session. When
you combine this data with other snapshots, the static information provides the means for separating
the individual data entries.
The example requires two FOR loops in this case. The first FOR command parses the file specifications
located in the DelFiles.
Pages:
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414