• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie: selecting newest file in a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie: selecting newest file in a folder


  • Subject: Re: Newbie: selecting newest file in a folder
  • From: Michelle Steiner <email@hidden>
  • Date: Thu, 19 Apr 2001 09:47:12 -0700

On 4/19/01 8:22 AM, email@hidden <email@hidden> wrote:

>I'd appreciate any tips on how to select the newest file in a folder
>(Newbie to creating AppleScripts).

<snip>

>I believe that I have everything working except how to select the newest
>log file. It would be the only one with a Date Modified that included
>"Today" (as long as I run the script daily). It is also the LAST item in
>the directory, since it is the newest. This shouldn't be very hard (and
>probably isn't) but I'm stumped and finding no answers in my web searches.

Items of a folder are sorted alphabetically, regardless of the creation
or modification dates, or the view sort.

If a file is generated only once a day, and the same time every day, the
script fragment below will return the most recent file. Actually, it
will return all files created within the past twenty-four hours.

--Michelle

tell application "Finder"
set x to the selection as alias
set y to (files of x whose (modification date) ,
is greater than ((current date) - 1 * days)) as alias list
end tell

Change the comma at the end of the third line to option-L to get it to
compile.

you'll also need to change the method of identifying the folder; I used
"the selection" for expediency in drafting the script.

--Michelle

----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------


  • Prev by Date: Newbie: selecting newest file in a folder
  • Next by Date: RE: Attaching a Folder Action
  • Previous by thread: Newbie: selecting newest file in a folder
  • Next by thread: Re: Newbie: selecting newest file in a folder
  • Index(es):
    • Date
    • Thread