|
Here we go abit rough at the edges but it seems to work.
;Script: Detect New File Presence ;Author: Richard Farthing@nhs.net ;Company: Queen Elizabeth Hospital NHS Trust ;Date: 08/10/03 ;Requirements: DirList Function
;Problems: When the message box appears telling the user that a ; new file has been created, it stops the script, ; so any new files added between clicking on OK will not be detected. ;***************************************************************************************
Break On
;Directory that you want to scan. $Directory = "C:\ScannedDocs"
;KiX Function DirList() Location Call 'D:\KiX\Functions\DirList()'
;Checking that scan directory exists If NOT Exist ($Directory) $null = MessageBox ("Error reading directory path","Error: "+@ERROR,0) Exit 1 EndIf
$DirList = DIRLIST($Directory+'\*.*',1+2) $FileCount = Ubound($dirlist) + 1 $Currentdirlist = DIRLIST($Directory+'\*.*',1)
While @Error = 0 ;Checking that scan directory exists within the loop If NOT Exist ($Directory) $null = MessageBox ("Error reading directory path","Error: "+@ERROR,0) Exit 1 EndIf $Current = $FileCount $dirlist = DIRLIST($Directory+'\*.*',1) $FileCount = Ubound($dirlist) + 1 Select ;Case statement for new files Case $FileCount > $Current $Count = Val(Ubound($dirlist)) + 1 ? 'File Added. Number of File(s): '+$Count For Each $File In $dirlist If AScan($Currentdirlist,$File) = "-1" $newfiledate = GetFileTime ("$directory\$File") $null = MessageBox ("There is a new file in the '$directory' folder"+@CRLF+"'$File' -- '$newfiledate'","New File !!",0) EndIf Next ;Case statement for deleted files Case $FileCount < $Current $Count = Val(Ubound($dirlist)) + 1 ? 'File Deleted. Number of File(s): '+$Count
EndSelect $Currentdirlist = DIRLIST($Directory+'\*.*',1) Sleep 2 Loop ;***************************************************************************************
[ 08. October 2003, 01:49: Message edited by: Richard Farthing ]
|