Open last modified file in directory?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Dman
Junior Coder
Posts: 26
Joined: Mon Apr 21, 2008 2:46 am
Location: Melbourne, Australia

Open last modified file in directory?

Post by Dman » Thu Apr 24, 2008 6:40 am

Hey all!

I've freshly purchased my Macro Scheduler Pro License! Woo! welcome to my own private outsourcer! haha.

Anyway my first thing I'd like to pick all of your collective brains on is how to automate the opening/selection of the last modified file in a directory?

I have a file which I now have a macro to create, which saves files with the current days date. I was going to have it do this to select the date:

Date>todaysdate
Sub>todaysdate,1 - but this wouldnt work so well for when the month rolls over.

Maybe I could have it say if todaysdate =1 then yesterday=31 - but then it would still rely on an assumption of the last day of last month.

If anyone could suggest a smarter way to do this, also appreciated =) Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Apr 24, 2008 7:23 am

Not sure why you think Sub>date,1 won't work when the month rolls over. Sub>date,1 subtracts 1 day from a date. If today is the first of the month, the result will be yesterday's date - the last of the previous month.

But for more ways to deal with dates please see:
http://www.mjtnet.com/blog/2006/01/23/u ... variables/

Here's a script called "Get last modified file in a directory":
http://www.mjtnet.com/forum/viewtopic.php?t=1462
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Dman
Junior Coder
Posts: 26
Joined: Mon Apr 21, 2008 2:46 am
Location: Melbourne, Australia

Post by Dman » Tue Apr 29, 2008 12:15 am

Perfect, thanks a lot

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts