Sequioa - asking for columns in Finder window's list view results in 256 list items

tell application "Finder" to set _c to every column of list view options of window 1

On Sequioa this results in 256 list items where items 1 thru 249 are “name column” and the rest are “real columns” like “modification date” etc.
Am I the only one?
Never had this on High Sierra :roll_eyes:

Thanks for any hint!

EDIT:

Okay, I found this thread:

The problem seems to have existed since at least 2019; probably in every macOS version since High Sierra.

Maybe this is what you want:

use scripting additions

tell application "Finder"
	activate
	set newWin to (make new Finder window with properties {current view:list view, sort column:name})
	set target of newWin to (path to desktop)
end tell

tell application "Finder" to set c to name of every column of list view options of Finder window 1

Result:

{name column, modification date column, creation date column, size column, kind column, label column, version column, comment column}
1 Like

Thank you very much, VikingOSX – I think this will help.

I was going to point out in response to VikingOSX’s suggestion that the Finder’s make command has an optional to parameter which can be used to specify the target of the Finder window being created:

tell application "Finder"
	activate
	set newWin to (make new Finder window to desktop with properties {current view:list view, sort column:name})
end tell

However, testing it in the above form before posting has led to the interesting discovery that, in the case of the desktop, the window that opens also contains the mounted volume(s) and groups the desktop items by stack, if any are set. The alternative forms below produce the same window contents as VikingOSX’s script:

tell application "Finder"
	activate
	set newWin to (make new Finder window to (path to desktop) with properties {current view:list view, sort column:name})
end tell
tell application "Finder"
	activate
	set newWin to (make new Finder window to folder "Desktop" of home with properties {current view:list view, sort column:name})
end tell

Thanks Nigel for the clarification. I thought I tested it this way but evidently not…

Could someone please try the following script?

  • I have 3 Finder windows open, all in list view

  • I activate window 1 and run the script
    Result of each variable = 8 items (= correct)

  • I activate window 2 and run the script
    Result of each variable = 16 items

  • I activate window 3 and run the script
    Result of each variable = 256 items

How can that be? I don’t understand this at all …

use scripting additions

tell application "Finder"
	activate
	set lview_options to list view options of window 1
	-- resulting variables lists:
	set lview_column_names to name of columns of lview_options
	set lview_column_visibles to visible of columns of lview_options
	set lview_column_widths to width of columns of lview_options
	set lview_column_sort_directions to sort direction of columns of lview_options
end tell