SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Get most recent file??

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Get most recent file??
Author Message
Jane Jackman



Joined: 18 Mar 2002
Posts: 3

Post Get most recent file?? Reply with quote

Has anyone got a script that gets the most recent file in a directory? I am trying to automate emailing a backup file and FileFindFirst seems to not have a sort option. I am using ver 2.4.

Cheers,

Jane

Mon Mar 18, 2002 12:26 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: Get most recent file?? Reply with quote

You can run external DIR with redirection than read the first line or loop through all files and compare their dates, both examples are below.

Example 1:
RunAndWait("cmd DIR /B/o-D c:\\mydir\\*.* > c:\\temp\\list.txt", "", 0, process)
FileReadLine("c:\\temp\\list.txt", 1, file_name)

Example 2:
You should get of each file date and time in a loop and then compare them to find the most recent.

Dim max_dt, datetime
Dim recent_file, string
Dim older, boolean
.... other declaration go here ....

FindFileFirst "c:\\mydir\\*.*", file_name, found

LoopWhile found, END_LOOP

FileDate file_name, date_val

FileTime file_name, time_val

MakeDateTime date_val, time_val, datetim_val

isLess datetim_val, max_dt, older

IfThen older, GET_NEXT

Set max_dt, datetime, val

Set recent_file, file_name

GET_NEXT:

FindFileNext file_name, found
END_LOOP:

// ok , recent_file variable has the name of the most recent file

: Has anyone got a script that gets the most recent file in a directory? I am
: trying to automate emailing a backup file and FileFindFirst seems to not
: have a sort option. I am using ver 2.4.

: Cheers,

: Jane

Mon Mar 18, 2002 1:15 pm View user's profile Send private message
Jane Jackman



Joined: 18 Mar 2002
Posts: 3

Post Re: Get most recent file?? Reply with quote

Thanks for that.

Jane

Mon Mar 18, 2002 5:02 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.