When I change the visible
property of a Finder column to false
it does not have any effect even after closing and reopening the window.
tell application "Finder"
activate
set visible of column id kind column of list view options of Finder window 1 to false
end tell
It appears to be a bug. Any workarounds?
Best Answer
I do not believe it's a bug because if you look at the AppleScript Dictionary for Finder, it shows the following for
list view options
as a property:The user cannot change a read only property, however there is a UI Scripting solution.
That said, I try to avoid UI Scripting whenever possible however, I have the daily need to open an external drive in a particular view, sorted by size and to do this a UI Scripting solution was this only choice I could find.
I've taken the relevant example AppleScript code from it to toggle the visibility of the Kind column:
Note that this particular UI Scripting solution does open and close the View Options for the front Finder window and is a bit of a visual distraction and one of the reasons I dislike UI Scripting however, sometimes one has no other choice to accomplish a given task. Note that I'm not saying it cannot be done any other way, just at the present time I don't know another way.
Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the
try
statement anderror
statement in the AppleScript Language Guide. See also Working with Errors. Additionally, UI Scripting may require the use of thedelay
command as appropriate, needed or wanted.