Mac Applescript question- how to expand folder in finder

DarJ

macrumors newbie
Original poster
Apr 7, 2010
5
0
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.
 

larkost

macrumors 6502a
Oct 13, 2007
536
1
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:
Code:
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
 

mysterytramp

macrumors 65816
Jul 17, 2008
1,335
3
Maryland
Why wouldn't this work:

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