Wednesday, January 19, 2022

#1 2021-12-04 11:45:21 pm

From:: Greece
Registered: 2019-03-03
Posts: 2208

Sort Finder selection by property using Choose From List

I again needed this helpful topic, in which @Nigel Garvey provided a solution, and I tried to supplement it with Choose From List functionality in post #3.

Since then I have gained some experience, and now I see the following improvement (code reduction) may be useful for users:


-- get Finder selection, sorted by criteria chosen in the Choose From List

tell application "Finder" to set sortOrders to {a reference to name, a reference to kind, a reference to creation date, a reference to modification date, a reference to size, a reference to comment, a reference to version, a reference to label index}
set sortOrderNames to {"Name", "Kind", "Creation Date", "Modification Date", "Size", "Comment", "Version", "Label Index"}

set sortOrder to choose from list sortOrderNames with prompt "Choose Method to Sort By"
if sortOrder is false then return
set sortOrder to item 1 of sortOrder
repeat with aPosition from 1 to count sortOrderNames
   if item aPosition of sortOrderNames is sortOrder then exit repeat
end repeat

tell application "Finder" to sort selection by (item aPosition of sortOrders)

Last edited by KniazidisR (2021-12-04 11:52:55 pm)

Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)