With AppleScript I know how to get the first or last file in a folder, f ex:
______________________________________________________________________
Hey Omar
get first file of folder alias "MacHD:Users:okn:Documents:_Output:”
You don't need folder in this context.
But I need the last file (by property?!) Modification date.
Also maybe one should first set the folder window to sort by Modification date, so that the latest file to have been added to the folder _Output would be uppermost?!
--------------------------------------------------- set _fldr to (path to downloads folder)
tell application "Finder" first file of _fldr as alias end tell ---------------------------------------------------
Note as alias. This is always faster than returning a Finder-reference.
Note too that if you run this, change the sort in the Finder window, and run it again that the item found will NOT change.
One way to do this is using the Finder:
--------------------------------------------------- set _fldr to path to downloads folder
tell application "Finder" set lastFile to (last item of (sort files of _fldr by modification date)) as alias end tell ---------------------------------------------------
The pitfall is that this can be very slow on pre-Mavericks systems (Mavericks seems to have made some improvement, but it's still not instant).
A faster method is:
------------------------------------------------------------------------------------------- set _path to POSIX path of (path to downloads folder as text) set lastModifiedFile to first paragraph of (do shell script "ls -Ft " & quoted form of _path & " | sed -E '/\\/$/d'") -------------------------------------------------------------------------------------------
-- Best Regards, Chris
|