script is cutting off everything after a period mark in the filename..

here’s the script. it works great for converting freehand files to illustrator, but whenever theres a file like “sp1293 st. croix” the new file becomes “sp1293 st.ai” the .ai in the filename is also problematic because spotlight wont search through it. the .ai does not get put on when everything else goes right in the script, btw.

thanks,
jordan


on open theseFiles
	repeat with thefile in theseFiles
		tell application "Finder"
			set {original_filename, savepath} to {name, container} of thefile
			if original_filename contains "FH-OLD" then
				set nofhold to text 1 thru -7 of original_filename
				set name of thefile to nofhold
				set original_filename to nofhold
			end if
			try
				set newName to ("^" & (text 1 thru 20 of original_filename) & ".EPS")
			on error
				set newName to ("^" & (text of original_filename) & ".EPS")
			end try
		end tell
		with timeout of 800 seconds
			tell application "FreeHand MX"
				activate
				open thefile
				save document 1 in file ((savepath as text) & newName) as GenericEPS with IncludeFHDocInEPS
				close document 1 saving no
			end tell
		end timeout
		
		tell application "Finder" to set name of thefile to text of original_filename & "FH-OLD"
		set epsPath to ((savepath as text) & newName)
		set olddelims to AppleScript's text item delimiters
		tell application "Adobe Illustrator" -- Will also work in AI 10.
			activate
			open file epsPath
			set ruler origin of current document to {0.0, 0.0}
			set position of group item 1 of layer 1 of current document to {10, 600}
			save current document in ((savepath as text) & original_filename) as Illustrator with options {compatibility:Illustrator 13, compressed:false, embed ICC profile:true, embed linked files:true, font subset threshold:100, PDF compatible:true}
		end tell
		tell application "Finder" to delete file epsPath
		set AppleScript's text item delimiters to olddelims
	end repeat
end open

I gather from your script that you want to preserve the original base name (without extension) and append a new extension. I use this script to extract basenames.

set f to (choose file) -- for illustration purposes; you'd feed in a filename.
tell (info for f) to set {Nm, Ex} to {name, name extension}
set BN to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
BN

Then you can append the new extension after the conversion. The script will ignore any intermediate periods or spaces in the name; it’s looking for period followed by the extension.