Sign in to follow this  
Followers 0
azoth

Help Me Please ! Need Support For Date And Directory

7 posts in this topic

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

Share this post


Link to post
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)

Share this post


Link to post
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 !! :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Micha1405

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Thanks you so much !!! :(

I'll try your solutions and return the feedback

Great forum with active members !!! :)

Share this post


Link to post
Share on other sites

YEAHH !!!! It works !!!

Very big thanks to all !!!

I'm happy !!! :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0