PcExpert Posted May 24, 2006 Share Posted May 24, 2006 (edited) Hello,This is another question for my updater. Is it possible to download a file with the most recent date in it's filename. For example:Files on server:7-5-2006.exe11-31-2005.exe12-12-2004.exeNow it checks for the latest date available: So in this case it will download the file: 7-5-2006.exeIf the file is already downloaded and it is already installed, it tells you that there's no update available.Thanks,PcExpert Edited May 24, 2006 by PcExpert Link to comment Share on other sites More sharing options...
Don N Posted May 24, 2006 Share Posted May 24, 2006 expandcollapse popup;change the working directory FileChangeDir( ".\test" ) ;get the first file $search = FileFindFirstFile( "*.*" ) If $search = -1 Then MsgBox( 0, "ERROR!", "There are no files or could not connect to remote directory" ) EndIf Dim $newest While 1 $file = FileFindNextFile( $search ) If @error Then MsgBox( 0, "Search Complete", "All files checked. Newest is " & $newest[1] & "-" & $newest[2] & "-" & $newest[3] ) ExitLoop EndIf If Not IsArray( $newest ) Then $newest = StringSplit( $file, "-" ) $newest[3] = StringLeft( $newest[3], StringInStr( $newest[3], "." ) - 1 ) Else $temp = StringSplit( $file, "-" ) $temp[3] = StringLeft( $temp[3], StringInStr( $temp[3], "." ) - 1 ) If ( $temp[3] > $newest[3] ) Then $newest = $temp EndIf If ( $temp[3] = $newest[3] ) Then If ( $temp[2] >= $newest[2] ) Then If ( $temp[2] = $newest[2] ) Then If $temp[1] > $newest[1] Then $newest = $temp EndIf Else $newest = $temp EndIf EndIf EndIF EndIf ToolTip( $newest[1] & "-" & $newest[2] & "-" & $newest[3]) Sleep( 1000 ) WEnd This should work for what you need, let me know how it turns out. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
PcExpert Posted May 25, 2006 Author Share Posted May 25, 2006 It doesn't work, I get the following error: Line 35 (File "D:\A. THUIS\test.au3"): $newest[3]= StringLeft( $newest[3], StringInStr( $newest[3], "." ) - 1 ) ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Link to comment Share on other sites More sharing options...
Don N Posted May 25, 2006 Share Posted May 25, 2006 are ur files definitely in the format "month-day-year.*" if not this will not work _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
GEOSoft Posted May 25, 2006 Share Posted May 25, 2006 (edited) It doesn't work, I get the following error: Line 35 (File "D:\A. THUIS\test.au3"): $newest[3] = StringLeft( $newest[3], StringInStr( $newest[3], "." ) - 1 ) ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.That error is telling you that $newest is either not an array or the array is not properly dimensioned. Use message boxes in place of Line 35 to test it If IsArray($newest) then MsgBox(4096,'Array?','You bet it is and it has a dimension of ' & $newest[0]) Else MsgBox(4096,'Error',' You still have work to do') EndIf You might also want to take a look at FileGetTime in the help file instead of using a date for the file name. Edited May 25, 2006 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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