0

I'm trying to make a button on finders toolbar that will group the open folders items by kind and sort by name. I found a script online that ive modified that appears to do this, t stops after changing to icon view and doesnt appear to do anything else.

tell application "Finder"
    
    
    activate
    
    tell the front Finder window
        set the current view to icon view
        set the toolbar visible to true
    end tell
    
            
    tell icon view options of front Finder window
        set properties to {sort column:name column, sort direction:normal, text size:12, uses relative dates:true, calculates folder sizes:true, shows icon preview:true}
    end tell
    
            
    tell application "System Events" to tell process "Finder"
        tell menu item "Show View Options" of menu of menu bar item "View" of menu bar 1 to if exists then click
        tell checkbox "Always open in icon view" of window 1 to if (exists) and value is 0 then click
        tell checkbox "Always open in list view" of window 1 to if (exists) and value is 1 then click
        tell checkbox "Date Modified" of group 1 of window 1 to if (exists) and value is 1 then click
        tell checkbox "Date Created" of group 1 of window 1 to if (exists) and value is 1 then click
        tell checkbox "Size" of group 1 of window 1 to if (exists) and value is 1 then click
        tell checkbox "Kind" of group 1 of window 1 to if (exists) and value is 0 then click
        tell checkbox "Version" of group 1 of window 1 to if v(exists) and alue is 1 then click
        tell checkbox "Comments" of group 1 of window 1 to if (exists) and value is 1 then click
        tell checkbox "Label" of group 1 of window 1 to if (exists) and value is 1 then click
    end tell
    
end tell
4
  • The last two lines are 'orphans', clickbutton & clickmenu. It won't compile with those as they are. Where did you get it from & what did you change?
    – Tetsujin
    Nov 17, 2022 at 8:14
  • i got it from here: discussions.apple.com/thread/3533331 and changed references of list view to icon view
    – SUBZ3RO
    Nov 17, 2022 at 8:18
  • Both lines are just missing spaces, then - you can tell by the formatting. 'click button' & click menu' will compile.
    – Tetsujin
    Nov 17, 2022 at 8:23
  • I'm barely halfway through my first coffee of the day;) but if you click the compile icon [hammer] it will tell you [near] where the error is.
    – Tetsujin
    Nov 17, 2022 at 8:24

1 Answer 1

0

Presume you've entered the script into Automator.app as a Quick Action. After editing the Apple Script press the hammer (🔨) button to compile and reformat the code. If errors exist (as they do) you'll get an error and the code is not reformatted.

3
  • thanks, i compiled it and no longer get an error, but it doesnt seem to group and sort the folder contents either - it opens the view options pane and stops at that.
    – SUBZ3RO
    Nov 17, 2022 at 8:33
  • Where are you running it from? If you run it in script editor it will tell you each time where the error is. I'm not sure what you're actually trying to achieve, but Icon View doesn't have columns you can set, so very few of those options are available to you.
    – Tetsujin
    Nov 17, 2022 at 14:07
  • @SUBZ3ERO Is the fixed code shared (Sorry, perhaps you updated the question with the fixed code)?
    – alls0rts
    Jan 6, 2023 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .