avprerunners Posted March 20, 2006 Share Posted March 20, 2006 Hi all, Im new to autoit (just started learning it last week)..any how ive searched High and Low for 3 days now trying to figure out how to do the following: I need to search all of drive c: and drive h: (it cant search other drives) for all files with a certain name (in.mbx). Once i have all the files i need to get the PATH of the Newest (last modified) Version of (in.mbx) and set that path as a Varaible that i can use later in my script I am using the newest beta of autoit 3. Thanks in advance for any help =) Brandon Link to comment Share on other sites More sharing options...
GaryFrost Posted March 20, 2006 Share Posted March 20, 2006 http://www.autoitscript.com/forum/index.ph...ndpost&p=132186 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
avprerunners Posted March 20, 2006 Author Share Posted March 20, 2006 http://www.autoitscript.com/forum/index.ph...ndpost&p=132186Been there tryed that..I saw all that stuff but i cant figure out how to make it all work togather..Below is good if i could make it do recursive of C: as well as H:..This code finds the newest as well as gets me the path of the newest file.#include <GUIConstants.au3>#Include <File.au3>#Include <Array.au3>$folder = 'c:\'$search = FileFindFirstFile($folder & "*.txt")$now = 0 $newest = ""While 1 $file = FileFindNextFile($search)if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIfWEndMsgBox(0,"Newest",$newest & " is your newest file, created : " & $now) Link to comment Share on other sites More sharing options...
nfwu Posted March 20, 2006 Share Posted March 20, 2006 #include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> $folder = 'c:\' $search = FileFindFirstFile($folder & "*.txt") $now = 0 $newest = "" While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf WEnd $folder = "h:\" $search = FileFindFirstFile($folder & "*.txt") While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf Wend MsgBox(0,"Newest",$newest & " is your newest file, created : " & $now) This??? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
avprerunners Posted March 20, 2006 Author Share Posted March 20, 2006 #include <GUIConstants.au3> #Include <File.au3> #Include <Array.au3> $folder = 'c:\' $search = FileFindFirstFile($folder & "*.txt") $now = 0 $newest = "" While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf WEnd $folder = "h:\" $search = FileFindFirstFile($folder & "*.txt") While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf Wend MsgBox(0,"Newest",$newest & " is your newest file, created : " & $now) This??? #) No that still dosent do recursive(all of c: and all oh H: and then find the newest file) I do appreachate the help tho..this stuff is stumping me...lol Brandon Link to comment Share on other sites More sharing options...
nfwu Posted March 20, 2006 Share Posted March 20, 2006 Func _FindRecursiveNewest($folder, $filetype) Local $search = FileFindFirstFile($folder&"\"&$filetype) Local $now, $newest If $search = -1 Then Return "NONE" While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf If StringInString(FileGetAttrib($folder&$file), "D") And (not stringInString($file, ".."))Then $result = _FindRecursiveNewest($folder&$file&"\", $filetype) If $result <> "NONE" THen If $result[0] > $now Then $now = $result[0] $newest = $result[1] Endif EndIf Endif Wend Local $ret[2] $ret[0] = $now $ret[1] = $newest return $ret EndFunc $c_dir = _FindRecursiveNewest("C:\", "*.txt") $h_dir = _FindRecursiveNewest("H:\", "*.txt") msgBox(0, $c_dir[1], $c_dir[0]) msgBox(0, $h_dir[1], $h_dir[0]) #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
avprerunners Posted March 20, 2006 Author Share Posted March 20, 2006 Func _FindRecursiveNewest($folder, $filetype) Local $search = FileFindFirstFile($folder&"\"&$filetype) Local $now, $newest If $search = -1 Then Return "NONE" While 1 $file = FileFindNextFile($search) if @error Then ExitLoop if FileGetTime($folder & $file,0,1) > $now Then $now = FileGetTime($folder & $file,0,1) $newest = $folder & $file EndIf If StringInString(FileGetAttrib($folder&$file), "D") And (not stringInString($file, ".."))Then $result = _FindRecursiveNewest($folder&$file&"\", $filetype) If $result <> "NONE" THen If $result[0] > $now Then $now = $result[0] $newest = $result[1] Endif EndIf Endif Wend Local $ret[2] $ret[0] = $now $ret[1] = $newest return $ret EndFunc $c_dir = _FindRecursiveNewest("C:\", "*.txt") $h_dir = _FindRecursiveNewest("H:\", "*.txt") msgBox(0, $c_dir[1], $c_dir[0]) msgBox(0, $h_dir[1], $h_dir[0]) #) 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