Converting an EPS to PDF file (pt 2)

Hi
I’ve got the following script which I’ve modified;

on open these_items
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the_file_name to name of (info for this_item) as string
		set Charcount to count characters of the_file_name
		set newName to characters -5 thru -Charcount of the_file_name as string
		set this_item to newName
		set theFilePath to (item i of these_items as string)
		set thePOSIXFilePath to POSIX path of theFilePath as string
		processFile(thePOSIXFilePath)
	end repeat
end open

on processFile(this_item)
	try
		set terminalCommand to ""
		set convertCommand to "/System/Library/Printers/Libraries/./convert "
		set newFileName to this_item & ".pdf"
		set terminalCommand to convertCommand & "-f " & "\"" & this_item & "\"" & " -o " & "\"" & newFileName & "\"" & " -j \"application/pdf\""
		do shell script terminalCommand
	end try
end processFile

The script works fine, however, when it saves the file it names it filename.eps.pdf I want it to save it as filename.pdf. Can someone suggest how I can get it to get rid of the .eps out of the saved filename. Also, I’d like to rewrite it to remove the repeat loop as it only has to process one file at a time as part of a larger script
ta!!

Change the line in the processFile handler to:

set newFileName to removeExt(this_item) & ".pdf"

Then add the following handler:

on removeExt(thisItem)
	set thisItem to thisItem as text
	set myOffset to offset of "." in (reverse of characters in thisItem as text)
	if myOffset ≠ 0 then set thisItem to characters 1 thru -(myOffset + 1) of thisItem as text
	return thisItem
end removeExt

That works perfectly!! Thanks for your help