Finder selection
Last modification: Monday, August 25, 2008 12:47 amReturns the selection of the frontmost Finder window respecting the sort state of the window.
Function Calls
finderSelection()Implementation
on finderSelection()-- Get the current Finder selection and sort it the same way it is sorted in the current window
tell application "Finder"
set _selectedFinderItems to selection
if _selectedFinderItems is {} then return {}
try
set _frontWindow to window 1
set _currentView to current view of _frontWindow
if _currentView is icon view then
-- The window is in icon view
set _arrangement to arrangement of icon view options of _frontWindow
if _arrangement is arranged by modification date then
set _sortProperty to "modification date"
else if _arrangement is arranged by creation date then
set _sortProperty to "creation date"
else if _arrangement is arranged by size then
set _sortProperty to "size"
else if _arrangement is arranged by kind then
set _sortProperty to "kind"
else if _arrangement is arranged by label then
set _sortProperty to "label"
else
set _sortProperty to "name"
end if
else if _currentView is list view then
-- The window is in list view
set _sortColumnName to name of sort column of list view options of _frontWindow
if _sortColumnName is modification date column then
set _sortProperty to "modification date"
else if _sortColumnName is creation date column then
set _sortProperty to "creation date"
else if _sortColumnName is size column then
set _sortProperty to "size"
else if _sortColumnName is kind column then
set _sortProperty to "kind"
else if _sortColumnName is label column then
set _sortProperty to "label"
else
set _sortProperty to "name"
end if
else
-- The window is in some other view
set _sortProperty to "name"
end if
on error
set _sortProperty to "name"
end try
-- Sort the list of selected items
if _sortProperty is "name" then
set _selectedFinderItems to sort _selectedFinderItems by name
else if _sortProperty is "modification date" then
set _selectedFinderItems to sort _selectedFinderItems by modification date
else if _sortProperty is "creation date" then
set _selectedFinderItems to sort _selectedFinderItems by creation date
else if _sortProperty is "size" then
set _selectedFinderItems to sort _selectedFinderItems by size
else if _sortProperty is "kind" then
set _selectedFinderItems to sort _selectedFinderItems by kind
else if _sortProperty is "label" then
set _selectedFinderItems to sort _selectedFinderItems by label
end if
end tell
return _selectedFinderItems
end finderSelection