sybex.com/WileyCDA/.
Listing 5.6: Adding Descriptive Information to a Data File
@ECHO OFF
REM Create a new environment variable with the identifying
REM information for this file. Start with the computer and
REM user name.
SET DataStore=%COMPUTERNAME%
SET DataStore=%DataStore%_%USERNAME%
REM Add the date.
SET DataStore=%DataStore%_%DATE:~4,2%
SET DataStore=%DataStore%_%DATE:~7,2%
SET DataStore=%DataStore%_%DATE:~10,4%
REM Add the time.
SET DataStore=%DataStore%_%TIME:~0,2%
SET DataStore=%DataStore%_%TIME:~3,2%
SET DataStore=%DataStore%_%TIME:~6,2%
REM Add the file extension.
:SetExtension
SET DataStore=%DataStore%.TXT
REM Locate all of the temporary files on your hard drive.
@ECHO Locating temporary files to delete.
@ECHO Saving files to ???%DataStore%???.
FOR /F %%F IN (DelFiles.TXT) DO Dir %%F /B /S >> ???%DataStore%???
@ECHO ON
In this example, the batch files build up an environment variable named DataStore that contains
the computer and usernames, along with the date and time. Obtaining the computer and usernames
are simply a matter of using the existing %COMPUTERNAME% and %USERNAME% environment
variables. However, the date and time prove more interesting.
Pages:
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410