erifash Posted March 29, 2005 Share Posted March 29, 2005 Using the _FileSearch function I was able to create a script that checks the current drive it is executed in for new or modified files. It's definition of new or modified is within the last three days. I use it to see the scripts I was working on yesterday (I easily forget). Here it is: expandcollapse popup$drv = StringTrimRight(@ScriptDir, StringLen(@ScriptDir) - 2) & "\" $a = _FileSearch($drv & "*.*",1) $newfiles = "" If $a[0] > 0 Then For $i = 1 to $a[0] If _IsNew($a[$i]) = 1 Then $newfiles = $newfiles & $a[$i] & @CRLF Next FileWrite("mod.log", "Scan of drive " & StringTrimRight(@ScriptDir, StringLen(@ScriptDir) - 2) & "\" & " for new or modified files:" & @CRLF & @CRLF & $newfiles) Sleep(500) Run(@SystemDir & "\notepad.exe " & @ScriptDir & "\mod.log", @SystemDir, @SW_MAXIMIZE) Sleep(500) FileDelete(@ScriptDir & "\mod.log") EndIf Func _IsNew($szfile) $time = @YEAR & @MON & ( @MDAY - 3 ) & @HOUR & @MIN & @SEC If Int(FileGetTime($szfile, 0, 1)) < Int($time) Then Return 0 Else Return 1 EndIf EndFunc Func _FileSearch($szMask,$nOption) $szRoot = "" $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If Not StringInStr($szMask,"\") Then $szRoot = @SCRIPTDIR & "\" Else While StringInStr($szMask,"\") $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\")) $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\")) Wend EndIf If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn) Else While 1 $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList,1) $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\" $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1) Wend EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn,1),"*") EndIf EndFunc;==>_FileSearch Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." Then _ $RETURN = $RETURN & $ROOT & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf EndFunc;==>_FileSearchUtil Although I think there might be some bugs... idk. My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now