azoth Posted May 5, 2006 Share Posted May 5, 2006 Hello, Im totally noob in AutoIt scripting ... But i want to progress !! How can i retrieve the last file created in a given directory? Some specs : - I have a directory with some files in it - All files are finished by a .log - And all days, a new .log is created I would like to retrieve the last file created and compare it with the system date (like _Now i imagine) Many thanks for the help !!! Link to comment Share on other sites More sharing options...
Simucal Posted May 5, 2006 Share Posted May 5, 2006 Hello,Im totally noob in AutoIt scripting ...But i want to progress !!How can i retrieve the last file created in a given directory? Some specs : - I have a directory with some files in it- All files are finished by a .log- And all days, a new .log is createdI would like to retrieve the last file created and compare it with the system date (like _Now i imagine)Many thanks for the help !!!Is there a particular pattern to the naming of the log files? AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
azoth Posted May 6, 2006 Author Share Posted May 6, 2006 Is there a particular pattern to the naming of the log files?Whaooo ! Thanks for the reply ! In fact, the files are created with NTBackup like: back01.log back02.log ... I can retrieve the last file by name but when NTBackup have made his last log, It recreate a new one with the same name, like this : back01.log back02.log ... [new date] back01.log ... So i think that the most valuable solution is to compare the date of the file with the system date and not with the name of the log... but i don't now how can i do that !! Link to comment Share on other sites More sharing options...
Micha1405 Posted May 6, 2006 Share Posted May 6, 2006 (edited) Try this: required Beta #Include <File.au3> #Include <Array.au3> $SearchPath="c:\windows\system32" $SearchPattern="*.log" $FileList=_FileListToArray($SearchPath,$SearchPattern,1) If (Not IsArray($FileList)) and (@Error=1) then MsgBox(0,"","No files found") Exit EndIf dim $FileDateArray[1] for $i=1 to $FileList[0] _ArrayInsert($FileDateArray,$i,FileGetTime($SearchPath&"\"&$FileList[$i] ,1,1)&"|"&$FileList[$i]) next _ArraySort($FileDateArray,1) $ret=StringSplit($FileDateArray[0],"|") MsgBox(0,"","Newest file = "&$ret[2]) Edited May 6, 2006 by Micha1405 My TrayToolBar Link to comment Share on other sites More sharing options...
jefhal Posted May 6, 2006 Share Posted May 6, 2006 (edited) I would like to retrieve the last file created and compare it with the system date (like _Now i imagine)This would work too: RunWait(@comspec & ' /c ' & 'dir ' & @tempdir & '\*.log /b /o-d > ' & @TempDir & '\newest.txt',@TempDir,@SW_HIDE) $newest = FileReadLine(@TempDir & '\newest.txt') MsgBox(1,"Newest log file in @tempdir",$newest) Edited May 6, 2006 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
azoth Posted May 6, 2006 Author Share Posted May 6, 2006 Thanks you so much !!! I'll try your solutions and return the feedback Great forum with active members !!! Link to comment Share on other sites More sharing options...
azoth Posted May 6, 2006 Author Share Posted May 6, 2006 YEAHH !!!! It works !!! Very big thanks to all !!! I'm happy !!! 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