maximize finders column width

is there a way to maximize the finders column width with applescript?

Here’s how to get the names of the columns and their widths from the front finder window

tell application "Finder"
	set lview_options to list view options of window 1
	set lview_column_names to name of columns of lview_options
	set lview_column_widths to width of columns of lview_options
	set lview_columns_props to {}
	repeat with i from 1 to count of lview_column_names
		set end of lview_columns_props to {item i of lview_column_names, item i of lview_column_widths}
	end repeat
end tell
lview_columns_props

And here’s how to set the width of a column

tell application "Finder"
	set lview_column_name to name column
	set name_column_width to 200
	set (width of columns of list view options of window 1 whose name is lview_column_name) to name_column_width
end tell

cool! thanks!

is there a way to automatically set the width to the max size? let the finder look for the longest filename and set the column to that width?

:smiley:

Not that I know of. The only thing I can think of is to get the names of the items in the window, and then iterate through the names counting the number of letters to find the longest name, then estimating the size based on the longest length, and then manually setting the column width.

I you can figure out the needed column width for just one letter, then it should be easy to figure out the width for any number of letters.

Hi again!

so I tried combining the two scripts above so that it cycles through the column names and sets the width that’s specified. I’m not sure I did it right as nothing is happening.

what’s the right way of combining the two scripts?

thanks!

Here’s one way. You just need to make a list of the widths you want for the window as set in the variable new_widths

set new_widths to {100, 100, 100, 100, 100, 100, 100, 100}

tell application "Finder"
	set lview_options to list view options of window 1
	set lview_column_names to name of columns of lview_options
	
	repeat with i from 1 to count of lview_column_names
		set (width of columns of list view options of window 1 whose name is (item i of lview_column_names)) to (item i of new_widths)
	end repeat
end tell

Hi again regulus,

did you get this script to work on yours? because nothing seems to happen when I run it in mine.

is there any special way I need to run this as? like place it on a toolbar? (-because that didn’t work :P)

thanks

This script works on a FInder window when it is in list view mode, so all you need to do is open a Finder window, make sure it is is list view mode (not icon or column view) and run the script.

ah thanks! it works now! I’m guessing there’s no option for this with column view? i just checked the finder dictionary in script editor and didn’t find the name or other similar attributes in the column view options.

:frowning:

oh well.

Not that I can find.