home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / timevent / taskmstr / dircheck.tsk < prev    next >
Encoding:
Text File  |  1995-05-07  |  3.3 KB  |  111 lines

  1. // This is a simple batch file to check for, and potentially handle,
  2. // .TMP files left by some applications.  It can use a second file
  3. // (DIRCHECK.DAT) for the list of the sudirectories to be checked
  4. // or they can be pre-defined (which occurs in this case if the
  5. // DIRCHECK.DAT file is not found).
  6. //
  7. // The file can be created with most any text editor as long as the
  8. // output is ASCII and each entry is on a line which is terminated
  9. // with a carriage return and a line feed.
  10.  
  11.  
  12. // First, we will set our base Current Working Directory (CWD).
  13.  
  14. CD SYS:SYSTEM
  15. IF ERRORLEVEL THEN ECHO Unable to change to SYS:SYSTEM directory.
  16.  
  17.  
  18. // Next, an attempt will be made to OPEN the source file containing
  19. // the vol:path entries which we want to scan for .TMP files.
  20. // (Note: Only the file name is specified so the OPEN is relative
  21. // to the CWD - previously set to SYS:SYSTEM with CD.)
  22.  
  23. OPEN_READ SYS:SYSTEM\DIRCHECK.DAT
  24.  
  25.  
  26. // The source file could contain the following entries:
  27. // SYS:HOME\GUEST
  28. // SYS:HOME\SUPER
  29.  
  30.  
  31. // If the OPEN of the source file failed (ERRORLEVEL) then a couple
  32. // of minimal checks/entries are DEFINEd for use.
  33.  
  34. IF ERRORLEVEL
  35.   ECHO.
  36.   ECHO Unable to OPEN DIRCHECK.DAT argument file!
  37.   ECHO Using pre-defined entries.
  38.   DEFINE %0 SYS:HOME\GUEST
  39.   DEFINE %1 SYS:HOME\SUPER
  40. ENDIF
  41.  
  42.  
  43. // Now the actual processing starts.  The following WHILE/LOOP
  44. // will only execute as long as there is not an error.  (Note:
  45. // In this case a <TEST> is not required as error checking is
  46. // performed prior to entering the LOOP and within the LOOP.)
  47.  
  48. WHILE
  49.  
  50.  
  51.   // By checking for the existence of the source argument file, it
  52.   // can be determined if a READ is required to set %0 to the next
  53.   // argument.  If ERRORLEVEL is true, either the End Of File was
  54.   // reached or a problem was encountered while reading the file.
  55.  
  56.   IF EXIST SYS:SYSTEM\DIRCHECK.DAT THEN READ %0
  57.   IF ERRORLEVEL THEN BREAK
  58.  
  59.  
  60.   // An attempt is made to change to the new directory.  If an error
  61.   // occurs, there must have been a null entry due to an End Of File
  62.   // (EOF) condition on the READ or no more entries to SHIFT so ECHO
  63.   // a message and BREAK out of the WHILE/LOOP.
  64.  
  65.   ECHO.
  66.   ECHO Attempting to change to %0 directory.
  67.  
  68.   CD %0
  69.  
  70.   IF NOT ERRORLEVEL
  71.     ECHO Checking %0 for files...
  72.   ELSE
  73.     ECHO %0 - Unable to change directories!
  74.     CONTINUE
  75.   ENDIF
  76.  
  77.  
  78.   // Check if any .TMP files exist and ECHO an appropriate message.
  79.   // By removing the leading period on either of the lines after
  80.   // the ELSE, existing .TMP files could be deleted or renamed.
  81.  
  82.   IF NOT EXIST *.*
  83.     ECHO No files matching *.* found in %0 !
  84.   ELSEIF NOT EXIST *.TMP
  85.     ECHO No files matching *.TMP found in %0 !
  86.   ELSE
  87.     ECHO %0 has *.TMP files!
  88.     .DELETE *.TMP
  89.     .RENAME *.TMP *.SAV
  90.   ENDIF
  91.  
  92.  
  93.   // By checking for the existence of the source argument file, it
  94.   // can be determined if a SHIFT is required to set %0 to the next
  95.   // argument.  If ERRORLEVEL is true, argument %0 is null (usually
  96.   // indicating all arguments have been shifted).
  97.  
  98.   IF NOT EXIST SYS:SYSTEM\DIRCHECK.DAT THEN SHIFT
  99.   IF ERRORLEVEL THEN BREAK
  100.  
  101. // Resume processing at the WHILE statement.
  102.  
  103. LOOP
  104.  
  105.  
  106. // That's it!
  107.  
  108. ECHO.
  109. ECHO Finished!
  110.  
  111.