Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Applescript to switch between name, date & size columns in list view' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Applescript to switch between name, date & size columns in list view
Authored by: RacerOSX on May 06, '06 10:38:22PM

Here's an Applescript to switch columns in list view. Based on the previous one, but modified to switch between columns with default sort order. Added the sortColumn variable to shorten the length of the statements, but they're still pretty long. Do NOT shorten the if sortColumn is statements "column id name column of list view options of Finder window 1" parts to the "name column" version as in the original script. It doesn't work (at least on my system - OS X 10.4.5). Save it as a script and use QuicKeys or whatever to invoke it.


tell application "Finder"
	
	-- Bail if current window view is not List view
	if current view of window 1 is list view then
		
		-- Could take out the activate if you want (don't need it if you're already in the finder)
		activate
		
		-- In case the columns you want to sort by are not visible, turn them on. (add more here or modify as needed)
		if visible of column id name column of list view options of window 1 is false then
			set visible of column id name column of list view options of window 1 to true
		end if
		if visible of column id modification date column of list view options of window 1 is false then
			set visible of column id modification date column of list view options of window 1 to true
		end if
		if visible of column id size column of list view options of window 1 is false then
			set visible of column id size column of list view options of window 1 to true
		end if
		
		-- Switches between the name column (normal - a to z), modification date column (reversed - most recent first)
		-- and size column (reversed - largest first). this is how I normally use the columns, so modify as needed
		-- check for current sort column and change to next one
		set sortColumn to ""
		set sortColumn to sort column of list view options of window 1
		if sortColumn is column id name column of list view options of Finder window 1 then -- if name, set to date (reversed)
			set sort column of list view options of window 1 to column id modification date column of list view options of window 1
			set sort direction of column id modification date column of list view options of window 1 to reversed
		else
			if sortColumn is column id modification date column of list view options of Finder window 1 then -- if date, set to size (reversed)
				set sort column of list view options of window 1 to column id size column of list view options of window 1
				set sort direction of column id size column of list view options of window 1 to reversed
			else
				if sortColumn is column id size column of list view options of Finder window 1 then -- if size, set to name (normal)
					set sort column of list view options of window 1 to column id name column of list view options of window 1
					set sort direction of column id name column of list view options of window 1 to normal
				end if
			end if
		end if
	end if
end tell

-- 	switch the name of the column using any of the following names, name column, modification date column, size column,
--	kind column, label column, or comment column.

Note that this only switches one way (not like the Finder in Panther), where shift-control-tab reversed the order. However, the script is easily modified to switch the order by rearranging the if-then-else statement order. Save this as another script and you're good to go.
You can also change which columns or add/subtract columns by modifying the same if-then-else statement.



[ Reply to This | # ]