home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 18
/
boot-disc-1998-02.iso
/
Utils
/
Utility
/
ClckMn95
/
DEMOBACK.WIL
< prev
next >
Wrap
Text File
|
1995-04-16
|
5KB
|
137 lines
;****************************************************************************
;****************************************************************************
nTotDrives = 0
nTotDirs = 0
nTotFiles = 0
nTotNeedBackup = 0
;We'll send the information to Notepad...
Run ("Notepad.exe", "")
SendkeysTo ("Notepad - (Un", "!ft{delete}{tab}{delete}~")
SendkeysTo ("Notepad - (Un", "This WIL script is scanning all your local drives~")
SendkeysTo ("Notepad - (Un", "for any files that need backing up.~")
SendkeysTo ("Notepad - (Un", "(This may take several minutes to complete.)~~")
SendkeysTo ("Notepad - (Un", "This is the kind of process ClockMan could run late Sunday night~")
SendkeysTo ("Notepad - (Un", "so you have the data waiting for you Monday morning.~~~")
SendkeysTo ("Notepad - (Un", " # files ~")
SendkeysTo ("Notepad - (Un", "Drive # files needing backup~")
SendkeysTo ("Notepad - (Un", "----- -------------- --------------~")
szDrives = DiskScan (2) ;List of all local fixed drives.
nTotDrives = ItemCount (szDrives, " ")
for nDrive = 1 to nTotDrives
szThisDrive = ItemExtract (nDrive, szDrives, " ")
SendkeysTo ("Notepad - (Un", " %szThisDrive% ")
nDriveFiles = 0
nDriveNeedBackup = 0
gosub ScanADrive
SendkeysTo ("Notepad - (Un", " %nDriveFiles% %nDriveNeedBackup%~")
nTotFiles = nTotFiles + nDriveFiles
nTotNeedBackup = nTotNeedBackup + nDriveNeedBackup
next
SendkeysTo ("Notepad - (Un", " -------------- --------------~")
SendkeysTo ("Notepad - (Un", "Total: %nTotFiles% %nTotNeedBackup%~")
;Now let's make this a nice official-looking report...
SendkeysTo ("Notepad - (Un", "^{home}+{down 6}{delete}")
SendkeysTo ("Notepad - (Un", strcat(" Backup Report for: ", TimeDate(), "~"))
; We could print it too...
nRet = AskYesNo ("ClockMan WIL Sample", "Shall we send the report to the printer?")
if (nRet == @YES)
SendkeysTo ("Notepad - (Un", "!fp")
Display(10, "ClockMan WIL Sample", StrCat("Notepad will close after printing.", @CRLF, @CRLF, "Please wait..."))
endif
SendKeysTo ("Notepad - (Un", "!fxn")
exit
;****************************************************************************
; For a given drive szThisDrive, find all the files that need backing up, placing
; the total nTotNeedBackup.
;****************************************************************************
:ScanADrive
;First check on this drive's root files...
P = 0 ; Our parent's level.
L = 1 ; Keeps track of which directory Level we're working on.
K = 2 ; Our kids' level.
szThisDir%P% = szThisDrive
;DebugData (szThisDir%P%, "...")
:ForEachLevel
; First enumerate our child directories (if any)...
szDirs%L% = DirItemize (strcat(szThisDir%P%,"\*.*"))
nNumDirs%L% = ItemCount (szDirs%L%, " ")
;DebugData (strcat(strfill(" ",L*4)," ",nNumDirs%L%," dirs: "), szDirs%L%)
nThisDir%L% = 1
:ForEachSubdir
if nThisDir%L% > nNumDirs%L% then goto EndEachSubdir
szThisDir%L% = strcat(szThisDir%P%, "\", ItemExtract(nThisDir%L%,szDirs%L%," "))
;DebugData (strfill(" ",L*4), szThisDir%L%)
szDirs%K% = DirItemize (strcat(szThisDir%L%,"\*.*"))
nNumDirs%K% = ItemCount (szDirs%K%, " ")
if (nNumDirs%K% == 0) then goto NoChildren4ThisSubdir
; Repeat for each of our children...
nThisDir%L% = nThisDir%L% + 1
P = P + 1
L = L + 1
K = K + 1
goto ForEachLevel
:NoChildren4ThisSubdir
; Now check on this subdirectory's files...
szCFNBDir = szThisDir%L%
gosub CountFilesNeedingBackup
nDriveFiles = nDriveFiles + nCFNBTotFiles
nDriveNeedBackup = nDriveNeedBackup + nCFNBBackup
; Get next subdir...
nThisDir%L% = nThisDir%L% + 1
nTotDirs = nTotDirs + 1
goto ForEachSubdir
:EndIfSubdirHasChildren
:EndEachSubdir
P = P - 1
L = L - 1
K = K - 1
if (L > 0) then goto ForEachSubdir
:EndEachLevel
; Finally, check on this drive's root dir's files...
szCFNBDir = szThisDir%L%
gosub CountFilesNeedingBackup
nDriveFiles = nDriveFiles + nCFNBTotFiles
nDriveNeedBackup = nDriveNeedBackup + nCFNBBackup
return;
;****************************************************************************
; For a given directory path szCFNBDir, counts the number of files needing
; backing up & places it in nCFNBBackup.
;****************************************************************************
:CountFilesNeedingBackup
if (strsub (szCFNBDir, strlen(szCFNBDir), 1) <> "\")
szCFNBDir = strcat (szCFNBDir, "\") ; Make sure dirpath ends with "\"
endif
szCFNBFiles = FileItemize ("%szCFNBDir%*.*")
nCFNBTotFiles = ItemCount (szCFNBFiles, " ")
nCFNBBackup = 0
for nCFNB = 1 to nCFNBTotFiles ;For each file in the directory...
szCFNBFile = strcat(szCFNBDir, ItemExtract (nCFNB, szCFNBFiles, " "))
szCFNBAttr = FileAttrGet (szCFNBFile)
;DebugData (strcat(strfill(" ",L*4)," ",szCFNBFile," ",szCFNBAttr),"")
if (strsub(szCFNBAttr,2,1)=="A") ; This file needs backing up...
nCFNBBackup = nCFNBBackup + 1
endif
next
return