Problem browsing to nested folders

– This script navigates to the first outer folder in a Save As dialog in Preview
– How do I continue into the nested folders? I would think “double click” but I can’t make it happen.

– Looping almost this same snippet following a “New From Clipboard” command, I have been able to save and rename over a thousand embedded images from Filemaker databases via the Clipboard as individual jpeg’s, setting quality, etc successfully in appleScript. But it only works because the destination folder was selected before running the script. The only thing I can’t seem to make happen is to choose the folder within Applescript.

set saveToFile to “TestFile”
set firstFile to “lk” – “lk” in my case
set nestedFile1 to “Reference” – “Reference” in my case
activate application “Preview”
tell application “System Events”
tell process “Preview”
keystroke “S” using {command down, shift down}
repeat until sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
keystroke saveToFile
keystroke “D” using command down
tell pop up button 1 of group 2
click
click menu item firstFile of menu 1
– How do I unfocus the file name field so that the following keystroke will operate on the highlighted file, not in the text field?
keystroke nestedFile1
end tell
– It works to here (except for the focus issue if I haven’t left the window open and manually unfocused before running the script).
– The folder ‘nestedFile1’ is highlighted, but I can’t double click it
tell process “Preview” – doesn’t work I’ve tried to tell Preview and the Finder to double click, nothing
double click
end tell
end tell
end tell
end tell

Thanks for any help or references!

try it this way, the reference to the folder must be a POSIX path

set saveToFile to "TestFile"
set firstFile to "lk" -- "lk" in my case
set nestedFile1 to "/Users/myUser/documents"

activate application "Preview"
tell application "System Events"
	tell process "Preview"
		keystroke "s" using {command down, shift down}
		repeat until sheet 1 of window 1 exists
		end repeat
		tell sheet 1 of window 1
			keystroke saveToFile
			keystroke "g" using {command down, shift down}
			repeat until sheet 1 exists
			end repeat
			keystroke destinationFolder
			click button "Go" of sheet 1
			click button "Save"
		end tell
	end tell
end tell