convert Freehand 10 to Illustrator CS3

I need to script converting Freehand 10 (.fh10) files to AI CS3. This conversion is best done by “saving as” to an EPS file - AI’s “Freehand import” filter tends to munge the image.

The script below works, except for the “tell Illustrator” block. I haven’t been able to get AI to open the resulting EPS file - various errors result, depending on the syntax I try. AI will open the EPS consistently when I icon-drag the file by hand.

Part of the problem is that Freehand 10 has sketchy scripting support. “Save in [path] as MacEPS” works but doesn’t return anything, so there’s no result to pass to AI.

Any help is appreciated!

set the file_list to {}
set the rawName to ""
set the epsName to ""


tell application "Finder"
	set convertThese to (selection)
	
	repeat with convertMe in convertThese
		set the rawName to characters of (name of convertMe as string)
		set thePath to POSIX path of (container of convertMe as alias)
		set the epsName to (rawName) & ".eps" as string
		tell application "FreeHand 10"
			open convertMe
			tell document 1 of it -- yes, you really need this line for the save command to work
				save it in (thePath & the epsName) as MacEPS
				close it
			end tell
			set the file_list to the file_list & (thePath & the epsName)
		end tell
	end repeat
end tell

repeat with openMe in file_list
	tell application "Adobe Illustrator"
		open (openMe as alias)
	end tell
end repeat

Hey guess what. It works now.

Freehand by default saves the EPS file in the same folder as the original with “.eps” appended to the name, and it doesn’t seem to matter what else you try to make it do. Not that big a deal for me, but it would be nice if you could get it to rename the file and choose a new location!

set the file_list to {}
set the rawName to ""
set the epsName to ""
tell application "Finder"
	set convertThese to selection
	
	repeat with convertMe in convertThese
		if kind of convertMe is "DataTypeIPTC" then
			set the epsName to (name of convertMe as string) & ".eps"
			set thePath to (container of convertMe) as string
			tell application "FreeHand 10"
				open convertMe
				tell document 1 of it
					save it as MacEPS -- no path or filename specified, Freehand ignores it anyway
					close it
				end tell
				set the file_list to the file_list & (thePath & epsName)
			end tell
		end if
	end repeat
end tell

repeat with openMe in file_list
	tell application "Adobe Illustrator"
		open alias openMe
		tell document 1
			save it in (thePath as alias) as Illustrator
			close it
		end tell
	end tell
end repeat