Applescript question- how to expand folder in finder

Discussion in 'Mac Programming' started by DarJ, Apr 7, 2010.

  1. DarJ macrumors newbie

    Apr 7, 2010
    I have a python script that downloads many files and places the files into one of many directories, after which I manually perform some action on the file. I would like to have that script make a call to applescript (via osascript) to expand (toggle open) the folder within finder (but not open Finder, or at least not bring it to the foreground), so that the next time I open the Finder, I can more easily see which folders contain files needing to be processed. I currently color/label the folder, but it's a hassle to unlabel a folder when I'm done. It would be much easier to untoggle the folder in Folder. I've looked through various applescript books, but the closest thing I can find is `reveal` and `select`, which don't actually expand the folder. Can anybody point me in the right direction?

    Much appreciation in advance.
  2. larkost macrumors 6502a

    Oct 13, 2007
    Strangely this is not part of the normal AppleScript dictionary for the Finder, so you have to resort to GUI scripting to get it done... and even then it is not nice. As it happens I needed to script this out for a recorded demo, so have some code sitting around:
    tell application "System Events"
    	tell process "Finder"
    		set finderWindowEvents to the window named "Demo"
    		set targetOutline to outline 1 of scroll area 1 of splitter group 1 of finderWindowEvents
    		if the value of UI element 1 of group 1 of row 1 of targetOutline is 0 then
    			click UI element 1 of group 1 of row 1 of targetOutline -- the instadmg folder
    		end if
    	end tell
    end tell
  3. DarJ thread starter macrumors newbie

    Apr 7, 2010
  4. mysterytramp macrumors 65816


    Jul 17, 2008
    Why wouldn't this work:

    tell application "Finder"
    	open "Disk Name:First Folder:Second Folder:And So On:"
    end tell

Share This Page