I have not been able to figure out how to list the contents of a folder by modification date. The current list folder command only returns the result in alphabetical order. I need this result in the list format. Has anyone successfully been able to do this???
I assume you are referring to a Finder window. These can be viewed in three ways, and if you are viewing one as a list (Command-2), then clicking on the “Date Modified” bar (the Name bar is the default) will list by date modified. Clicking again will reverse the sort. Is that what you are looking for?
To do this with Applescript, try this with a window open in the Finder:
tell application "Finder"
activate
set current view of front Finder window to list view
set sort column of list view options of front Finder window to modification date column
set sort direction of column id modification date column of list view options of front Finder window to reversed
update folder of front Finder window
end tell
Sort Column is a property of List View Options of Finder window in the Finder Dictionary.
Best wishes
John M
If you’re looking to access them in order within a script, this should give you a list to step through:
set {saveTid, text item delimiters} to {text item delimiters, return}
set cmd to "ls -t " & quoted form of POSIX path of ((choose folder) as text)
set listSortedByModDate to text items of (do shell script cmd)
set text item delimiters to saveTid
listSortedByModDate
-Dan
[Emphasis added]
You could use the UNIX “ls” command:
choose folder
do shell script "ls -t " & quoted form of POSIX path of result
set fileList to paragraphs of result
Thanks, Bruce. ![]()
That is exactly what I was looking for.