Re: finding newest file in a folder
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.