home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 18 / boot-disc-1998-02.iso / Utils / Utility / ClckMn95 / DEMOBACK.WIL < prev    next >
Text File  |  1995-04-16  |  5KB  |  137 lines

  1. ;****************************************************************************
  2. ;****************************************************************************
  3. nTotDrives = 0
  4. nTotDirs = 0
  5. nTotFiles = 0
  6. nTotNeedBackup = 0
  7.  
  8. ;We'll send the information to Notepad...
  9. Run ("Notepad.exe", "")
  10. SendkeysTo ("Notepad - (Un", "!ft{delete}{tab}{delete}~")
  11. SendkeysTo ("Notepad - (Un", "This WIL script is scanning all your local drives~")
  12. SendkeysTo ("Notepad - (Un", "for any files that need backing up.~")
  13. SendkeysTo ("Notepad - (Un", "(This may take several minutes to complete.)~~")
  14. SendkeysTo ("Notepad - (Un", "This is the kind of process ClockMan could run late Sunday night~")
  15. SendkeysTo ("Notepad - (Un", "so you have the data waiting for you Monday morning.~~~")
  16.  
  17. SendkeysTo ("Notepad - (Un", "                          # files    ~")
  18. SendkeysTo ("Notepad - (Un", "Drive    # files       needing backup~")
  19. SendkeysTo ("Notepad - (Un", "-----  --------------  --------------~")
  20.                        
  21. szDrives = DiskScan (2) ;List of all local fixed drives.
  22. nTotDrives = ItemCount (szDrives, " ")
  23. for nDrive = 1 to nTotDrives
  24.     szThisDrive = ItemExtract (nDrive, szDrives, " ")
  25.     SendkeysTo ("Notepad - (Un", " %szThisDrive%    ")
  26.     nDriveFiles = 0
  27.     nDriveNeedBackup = 0
  28.  
  29.     gosub ScanADrive
  30.  
  31.     SendkeysTo ("Notepad - (Un", "    %nDriveFiles%             %nDriveNeedBackup%~")
  32.     nTotFiles = nTotFiles + nDriveFiles
  33.     nTotNeedBackup = nTotNeedBackup + nDriveNeedBackup
  34. next
  35.  
  36. SendkeysTo ("Notepad - (Un", "       --------------  --------------~")
  37. SendkeysTo ("Notepad - (Un", "Total:     %nTotFiles%             %nTotNeedBackup%~")
  38.  
  39. ;Now let's make this a nice official-looking report...
  40. SendkeysTo ("Notepad - (Un", "^{home}+{down 6}{delete}")
  41. SendkeysTo ("Notepad - (Un", strcat("       Backup Report for: ", TimeDate(), "~"))
  42.  
  43. ; We could print it too...
  44. nRet = AskYesNo ("ClockMan WIL Sample", "Shall we send the report to the printer?")
  45. if (nRet == @YES)
  46.     SendkeysTo ("Notepad - (Un", "!fp")
  47.     Display(10, "ClockMan WIL Sample", StrCat("Notepad will close after printing.", @CRLF, @CRLF, "Please wait..."))    
  48. endif
  49. SendKeysTo ("Notepad - (Un", "!fxn")
  50. exit
  51.  
  52.  
  53. ;****************************************************************************
  54. ; For a given drive szThisDrive, find all the files that need backing up, placing
  55. ; the total nTotNeedBackup.
  56. ;****************************************************************************
  57. :ScanADrive
  58. ;First check on this drive's root files...
  59. P = 0  ; Our parent's level.
  60. L = 1  ; Keeps track of which directory Level we're working on.
  61. K = 2  ; Our kids' level.
  62.  
  63. szThisDir%P% = szThisDrive
  64. ;DebugData (szThisDir%P%, "...")
  65.  
  66. :ForEachLevel
  67.     ; First enumerate our child directories (if any)...
  68.     szDirs%L% = DirItemize (strcat(szThisDir%P%,"\*.*"))
  69.     nNumDirs%L% = ItemCount (szDirs%L%, " ")
  70.     ;DebugData (strcat(strfill(" ",L*4)," ",nNumDirs%L%," dirs: "), szDirs%L%)
  71.     nThisDir%L% = 1
  72.  
  73.     :ForEachSubdir
  74.     if nThisDir%L% > nNumDirs%L% then goto EndEachSubdir
  75.         szThisDir%L% = strcat(szThisDir%P%, "\", ItemExtract(nThisDir%L%,szDirs%L%," "))
  76.         ;DebugData (strfill(" ",L*4), szThisDir%L%)
  77.         szDirs%K% = DirItemize (strcat(szThisDir%L%,"\*.*"))
  78.         nNumDirs%K% = ItemCount (szDirs%K%, " ")
  79.         if (nNumDirs%K% == 0) then goto NoChildren4ThisSubdir
  80.             ; Repeat for each of our children...
  81.             nThisDir%L% = nThisDir%L% + 1
  82.             P = P + 1
  83.             L = L + 1
  84.             K = K + 1
  85.             goto ForEachLevel
  86.         :NoChildren4ThisSubdir
  87.             ; Now check on this subdirectory's files...
  88.             szCFNBDir = szThisDir%L%
  89.             gosub CountFilesNeedingBackup
  90.             nDriveFiles = nDriveFiles + nCFNBTotFiles
  91.             nDriveNeedBackup = nDriveNeedBackup + nCFNBBackup
  92.         
  93.             ; Get next subdir...
  94.             nThisDir%L% = nThisDir%L% + 1
  95.             nTotDirs = nTotDirs + 1
  96.             goto ForEachSubdir
  97.         :EndIfSubdirHasChildren
  98.     :EndEachSubdir
  99.  
  100.     P = P - 1
  101.     L = L - 1
  102.     K = K - 1
  103.     if (L > 0) then goto ForEachSubdir
  104. :EndEachLevel
  105.  
  106. ; Finally, check on this drive's root dir's files...
  107. szCFNBDir = szThisDir%L%
  108. gosub CountFilesNeedingBackup
  109. nDriveFiles = nDriveFiles + nCFNBTotFiles
  110. nDriveNeedBackup = nDriveNeedBackup + nCFNBBackup
  111. return;
  112.  
  113.  
  114.  
  115. ;****************************************************************************
  116. ; For a given directory path szCFNBDir, counts the number of files needing
  117. ; backing up & places it in nCFNBBackup.
  118. ;****************************************************************************
  119. :CountFilesNeedingBackup
  120.     if (strsub (szCFNBDir, strlen(szCFNBDir), 1) <> "\")
  121.         szCFNBDir = strcat (szCFNBDir, "\") ; Make sure dirpath ends with "\"
  122.     endif
  123.  
  124.     szCFNBFiles = FileItemize ("%szCFNBDir%*.*")
  125.     nCFNBTotFiles = ItemCount (szCFNBFiles, " ")
  126.     
  127.     nCFNBBackup = 0
  128.     for nCFNB = 1 to nCFNBTotFiles  ;For each file in the directory...
  129.         szCFNBFile = strcat(szCFNBDir, ItemExtract (nCFNB, szCFNBFiles, " "))
  130.         szCFNBAttr = FileAttrGet (szCFNBFile)
  131.         ;DebugData (strcat(strfill(" ",L*4)," ",szCFNBFile," ",szCFNBAttr),"")
  132.         if (strsub(szCFNBAttr,2,1)=="A")  ; This file needs backing up...
  133.             nCFNBBackup = nCFNBBackup + 1
  134.         endif
  135.     next
  136. return
  137.