Jump to content

Help Me Please ! Need Support For Date And Directory


Recommended Posts

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

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 !!!

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

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

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 by Micha1405
Link to comment
Share on other sites

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 by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...