• 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: newest file in a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newest file in a folder


  • Subject: Re: newest file in a folder
  • From: "Marc K. Myers" <email@hidden>
  • Date: Mon, 18 Dec 2000 00:58:55 -0500
  • Organization: [very little]

Hevard wrote:
> Date: Sun, 17 Dec 2000 23:19:14 +0100
> To: email@hidden
> From: =?iso-8859-1?Q?H=E5vard?= <email@hidden>
> Subject: newest file in a folder
>
> What is the clean and easy way to get an alias to the newest file of
> a folder? (the one with the newest modification date.)
>
> if I
> tell app "Finder" to get first file of myFolder
> --> first file by name.
> How do I get "last file by date"?

If you want to do it without third-party scripting additions, this works:

tell application "Finder"
set fileList to (sort files of myFolder by modification date)
end tell
set newFile to (contents of item 1 of fileList) as alias

Marc [12/18/00 12:53:50 AM]


  • Prev by Date: Re: Remote Access
  • Next by Date: Re: Applet Icon is still AppleScript icon
  • Previous by thread: Re: newest file in a folder
  • Next by thread: Booleans in positional parameter sub routines
  • Index(es):
    • Date
    • Thread