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

Re: finding newest file in a folder


  • Subject: Re: finding newest file in a folder
  • From: Walter Ian Kaye <email@hidden>
  • Date: Sun, 14 Mar 2004 00:43:33 -0800

At 03:17a -0500 03/14/2004, Graff didst inscribe upon an electronic papyrus:

You can do something like this:
------------
tell application "Finder"
set theFolder to choose folder
set theItems to every item of theFolder
set latestItem to item 1 of theItems
set latestDate to creation date of latestItem
repeat with aItem in (rest of theItems)
set aDate to creation date of aItem
if aDate is greater than latestDate then
set latestItem to aItem
end if
end repeat

display dialog (name of latestItem) as text
end tell
------------

Umm... don't you have to update latestDate?

tell application "Finder"
set theFolder to choose folder
set theItems to every item of theFolder
set latestItem to item 1 of theItems
set latestDate to creation date of latestItem
repeat with aItem in (rest of theItems)
set aDate to creation date of aItem
if aDate is greater than latestDate then
set latestItem to aItem
set latestDate to aDate
end if
end repeat

display dialog (name of latestItem) as text
end tell


-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: finding newest file in a folder
      • From: Graff <email@hidden>
References: 
 >finding newest file in a folder (From: John Cochrane <email@hidden>)
 >Re: finding newest file in a folder (From: Graff <email@hidden>)

  • Prev by Date: Re: "Save changes to script" when it terminates?
  • Next by Date: Sending data direct to USB in OSX
  • Previous by thread: Re: finding newest file in a folder
  • Next by thread: Re: finding newest file in a folder
  • Index(es):
    • Date
    • Thread