Hi.
Here I wrote one script to sort contents of front Finder window by chosen column name. It works fine. The problem is that I want manage showed in Finder window columns too: remove some of them or add some of them.
The dictionary of the Finder has command make column, delete column, but I can’t understand its syntax. Here I need help.
property criteriaList : {"Date Modified", "Name", "Date Created", "Size", "Kind", "Version", "Comments", "Tags"}
set theFolder to (choose folder with prompt "SELECT A FOLDER, PLEASE.")
set theCriteria to item 1 of (choose from list criteriaList with prompt "CHOOSE A COLUMN TO SORT ITEMS, PLEASE")
-- OPEN FOLDER, WAIT WHILE FINDER WINDOW OPENS
tell application "Finder"
activate
tell folder theFolder
open
repeat until container window exists
delay 0.1
end repeat
end tell
end tell
-- GET TARGET, SET BOUNDS OF WINDOW, SET VIEW TO LIST VIEW
tell application "Finder" to tell folder theFolder
tell container window ---------------------------- window, which contains chosen folder
set currentTarget to target --------------- save target in variable to use it later
set theBounds to {35, 25, 1280, 805} --- save bounds to use it later
set bounds to theBounds
set current view to list view
end tell
end tell
-- SET LIST VIEW OPTIONS
tell application "Finder" to tell folder theFolder
tell container window to tell its list view options
set calculates folder sizes to true
set shows icon preview to false
set icon size to small icon
set text size to 12
set uses relative dates to false
end tell
end tell
-- SET SORT COLUMN
tell application "Finder" to tell folder theFolder
tell container window to tell its list view options
set theColumnsList to {column id modification date column, column id name column, ¬
column id creation date column, column id size column, column id kind column, ¬
column id version column, column id comment column, column id label column}
repeat with i from 1 to (count of criteriaList)
set theItem to item i of criteriaList
if theItem = theCriteria then ---------------------- determine which id column to use
set sort column to (item i of theColumnsList)
set sortColumn to sort column
set sort direction of sortColumn to normal -- or, to reversed
exit repeat
end if
end repeat
end tell
end tell
-- CLONE FINDER WINDOW, SET BOUNDS OF NEW WINDOW TO ONES OF OLD WINDOW
tell application "Finder"
make new Finder window to currentTarget
tell front Finder window to set bounds to theBounds
end tell
-- CLOSE ORIGINAL FINDER WINDOW (TO SEE THE CHANGES)
tell application "Finder" to close window 2