Quark 6.5 change font script

I am trying to create a script that will let the user choose to replace any current font in a Quark XPress 6.5 file with another available font. The thought is that this could be done on a folder by folder basis. Maybe I am thinking too abstractly for this to be practical… Not sure. I am able to get most of my variables working, but I am not sure how to design the script to be able to be scalable. In the end, this script could be used to swap fonts for dozens or hundreds of files. I know I may sound like I am smoking banana peels, but it seemed like a good idea at the time…


set FileSample to choose folder
set folderName to name of (info for FileSample)
tell application "Finder" to set theFiles to files of FileSample whose name extension is in {"qxd"} or kind contains "QuarkXPress" or file type is in {"XPRJ", "XPR3"}
repeat with i from 1 to count of theFiles
	set thisFile to item i of theFiles
	set thisFile to thisFile as alias
		tell application "QuarkXPress"
		open thisFile
		tell front document
			set fileName to name as string
			set allFonts to font list as list
			set inputFonts to font of every character of every story as list
			set outputFonts to choose from list allFonts
				set (font of every character of every story where font is inputFonts) to outputFonts
				beep 1
			on error
				display dialog "Font change failed."
			end try
		end tell
		close saving yes
	end tell
end repeat
display dialog "Done"

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox
Operating System: Mac OS X (10.4)