home *** CD-ROM | disk | FTP | other *** search
- // This is a simple batch file to check for, and potentially handle,
- // .TMP files left by some applications. It can use a second file
- // (DIRCHECK.DAT) for the list of the sudirectories to be checked
- // or they can be pre-defined (which occurs in this case if the
- // DIRCHECK.DAT file is not found).
- //
- // The file can be created with most any text editor as long as the
- // output is ASCII and each entry is on a line which is terminated
- // with a carriage return and a line feed.
-
-
- // First, we will set our base Current Working Directory (CWD).
-
- CD SYS:SYSTEM
- IF ERRORLEVEL THEN ECHO Unable to change to SYS:SYSTEM directory.
-
-
- // Next, an attempt will be made to OPEN the source file containing
- // the vol:path entries which we want to scan for .TMP files.
- // (Note: Only the file name is specified so the OPEN is relative
- // to the CWD - previously set to SYS:SYSTEM with CD.)
-
- OPEN_READ SYS:SYSTEM\DIRCHECK.DAT
-
-
- // The source file could contain the following entries:
- // SYS:HOME\GUEST
- // SYS:HOME\SUPER
-
-
- // If the OPEN of the source file failed (ERRORLEVEL) then a couple
- // of minimal checks/entries are DEFINEd for use.
-
- IF ERRORLEVEL
- ECHO.
- ECHO Unable to OPEN DIRCHECK.DAT argument file!
- ECHO Using pre-defined entries.
- DEFINE %0 SYS:HOME\GUEST
- DEFINE %1 SYS:HOME\SUPER
- ENDIF
-
-
- // Now the actual processing starts. The following WHILE/LOOP
- // will only execute as long as there is not an error. (Note:
- // In this case a <TEST> is not required as error checking is
- // performed prior to entering the LOOP and within the LOOP.)
-
- WHILE
-
-
- // By checking for the existence of the source argument file, it
- // can be determined if a READ is required to set %0 to the next
- // argument. If ERRORLEVEL is true, either the End Of File was
- // reached or a problem was encountered while reading the file.
-
- IF EXIST SYS:SYSTEM\DIRCHECK.DAT THEN READ %0
- IF ERRORLEVEL THEN BREAK
-
-
- // An attempt is made to change to the new directory. If an error
- // occurs, there must have been a null entry due to an End Of File
- // (EOF) condition on the READ or no more entries to SHIFT so ECHO
- // a message and BREAK out of the WHILE/LOOP.
-
- ECHO.
- ECHO Attempting to change to %0 directory.
-
- CD %0
-
- IF NOT ERRORLEVEL
- ECHO Checking %0 for files...
- ELSE
- ECHO %0 - Unable to change directories!
- CONTINUE
- ENDIF
-
-
- // Check if any .TMP files exist and ECHO an appropriate message.
- // By removing the leading period on either of the lines after
- // the ELSE, existing .TMP files could be deleted or renamed.
-
- IF NOT EXIST *.*
- ECHO No files matching *.* found in %0 !
- ELSEIF NOT EXIST *.TMP
- ECHO No files matching *.TMP found in %0 !
- ELSE
- ECHO %0 has *.TMP files!
- .DELETE *.TMP
- .RENAME *.TMP *.SAV
- ENDIF
-
-
- // By checking for the existence of the source argument file, it
- // can be determined if a SHIFT is required to set %0 to the next
- // argument. If ERRORLEVEL is true, argument %0 is null (usually
- // indicating all arguments have been shifted).
-
- IF NOT EXIST SYS:SYSTEM\DIRCHECK.DAT THEN SHIFT
- IF ERRORLEVEL THEN BREAK
-
- // Resume processing at the WHILE statement.
-
- LOOP
-
-
- // That's it!
-
- ECHO.
- ECHO Finished!
-