Controlling 'Export Multiple...' window in Audacity (audio app)

Hi I’ve got a large group of lectures on CD that I need to edit in Audacity.

(The actual editing has to be done by hand, so I’m trying to speed this up as much as possible; I’m also new to AppleScript so if you see a “design” flaw you might mention a better way to tackle any given part of the script.)

Structure: on the Desktop, folder named “Fr. Corapi CDs” containing folders “CD 01” thru “CD 49” each containing ~10-12 audio tracks (AIFF)

With the script below I’m stuck after selecting “Export Multiple…” because I can’t seem to be able to control the window. I’ve tried using Apple’s UIElementInspector but still can’t seem to gain any control. I’d like to be able to set the “Export location:” in the “Export Multiple…” window to the same folder I chose at the very beginning (set in var., this_folder). For anyone without this app on their system, the ‘Export Location:’ presents a text input field with POSIX style navigation (/Users/robert/Desktop/Fr. Corapi CDs/CD 08"), I just can’t seem to get applescript to recognize the window! Any help much appreciated! Thank you

global this_folder
global source_folder

set source_folder to "Mac.HD:Users:aggie4life:Desktop:Fr. Corapi CDs:" as alias
set this_folder to (choose folder with prompt ¬
	"Choose the CD to edit in Audacity:" default location source_folder) as string

tell application "Audacity"
	activate
end tell

tell application "System Events"
	keystroke "i" using {shift down, command down}
	set file_path_of_folder to POSIX path of folder this_folder
	keystroke "g" using {command down, shift down}
	keystroke file_path_of_folder
	keystroke return
	keystroke "a" using {command down}
	keystroke return
	displayMsg("Click 'OK' when you've finished editing all the tracks in a given album.", {"OK", "Cancel"}) of me
end tell


on displayMsg(theMessage, theButtons)
	display dialog theMessage buttons theButtons default button "OK"
	if theButtons = "Cancel" then
		exit repeat
	else
		exportFiles()
	end if
end displayMsg


on exportFiles()
	tell application "Finder"
		set label index of folder this_folder to 6
	end tell
	tell application "System Events"
		tell process "Audacity"
			activate
			click the menu item "Export Multiple..." of the menu "File" of menu bar 1
		end tell
	end tell
end exportFiles

Hi aggie4life

messy messy stuff, give the below a whirl aggie4life

tell application "System Events"
	tell process "Audacity"
		activate
		click menu item "Export Multiple..." of menu 1 of menu bar item "File" of menu bar 1
		tell application "Audacity"
			activate
			tell application "System Events"
				tell process "Audacity"
click menu 1 of menu bar item "Audacity" of menu bar 1
				end tell
			end tell
		end tell
	end tell
end tell

Budgie