• 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: Graff <email@hidden>
  • Date: Sun, 14 Mar 2004 03:17:57 -0500

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
------------

This example asks for a folder name but you can hard code it in by doing something like:
set theFolder to (path to documents folder as text) & "Scans"
set theItems to every item of folder theFolder

This will look for a folder named "Scans" in the documents folder of the current user.

The path of the latest created item will be in the variable latestItem.

-Ken

On Mar 14, 2004, at 1:06 AM, John Cochrane wrote:

Hello scripters.

I am trying to get a reference to a file that I have just scanned in to a folder. My scanning software won't get it for me so I thought I would try to identify it by finding the file of the 'scan_folder' whose creation date is latest.
I think a repeat loop is needed but can't seem to get it right.
I'd appreciate any pointers.
_______________________________________________
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: Walter Ian Kaye <email@hidden>
References: 
 >finding newest file in a folder (From: John Cochrane <email@hidden>)

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