Roy McCoy AS: Scripting Finder list views [was: Sort 'n stack]
Feb 05, 2010; 19:18
Roy McCoy
AS: Scripting Finder list views [was: Sort 'n stack]
P.S. I wrote:
> tell application "Finder" > set current view of window 1 to list view > set sort column of list view options of window 1 to name column > -- modification date column, kind column, label column, size column > if sort direction of column name column of list view options ¬ > of window 1 is reversed then > set sort direction of column name column of list view options ¬ > of window 1 to normal > else > set sort direction of column name column of list view options ¬ > of window 1 to reversed > end if > end tell > > [...] one thing I do want to do is reverse the sort direction only > if the sort column is already set to the one desired. That is, I want > to move the if/else statement to the beginning of the script and place > it inside another if statement testing for the current sort column. > But I couldn't figure out how to do that test.
Sorry if this wasn't clear, but I was in a slight rush this afternoon.
The problem was, and still is, that whereas I did want to add a toggle of the sort direction (you know, whether the arrow's up or down, whether for example it's newest or oldest at the top, A-Z or Z-A, etc.) to the script, I didn't want it to *invariably* toggle the sort direction as it does now. The solution would be simply to move the toggle to the start of the script and have it occur only if the desired column was already selected. Otherwise the script would simply switch to the right column and not toggle its sort direction. But the sort column you get from "sort column of list view options of Finder window 1" is, for example:
> column id name column of list view options of Finder window id 1630 > of application "Finder"
which contains info particular to one window, rather than general to any Finder window with (here) the name column selected. In other words, if I do:
if sort column of list view options of Finder window 1 is column id ¬ name column of list view options of Finder window id 1630 of ¬ application "Finder" then --do the toggle end if
it will work for this window, but not for others. So I guess I need to isolate the property... "column id" rather than "sort column", maybe... Nope... I just don't know how to do it. Anyone?
Ooh, here's an idea. I can put the original sort column in a variable, set the sort column to name or whatever, then put the sort column in another variable, compare the two variables and perform the toggle only if they're the same.
And that works. For example:
tell application "Finder" set current view of window 1 to list view set FirstSortColumn to sort column of list view options of window 1 set sort column of list view options of window 1 to ¬ modification date column set SecondSortColumn to sort column of list view options of window 1 if FirstSortColumn = SecondSortColumn then if sort direction of column modification date column of ¬ list view options of window 1 is reversed then set sort direction of column modification date column of ¬ list view options of window 1 to normal else set sort direction of column modification date column of ¬ list view options of window 1 to reversed end if end if end tell
Whew again. I can send a set of these to Richard or anyone else who might be interested. Those who are really uninterested should, again, filter out messages on this list with "AS:" in the subject line.
Roy -- This list is a free service of LassoSoft: http://www.LassoSoft.com/ Search the list archives: http://www.ListSearch.com/InDesign/Browse/ Manage your subscription: http://www.ListSearch.com/InDesign/
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!