Batch Illustrator Save EPS errors

I copied this script from a book called “Applescript for Applications (Visual QuickStart Guide)”. It is supposed to export Folders & Files in EPS format. It’s an old book but I like it.

I’m having the following issues:
Saved as script & running it from Applescript gives me this error:
error “Can’t make myFiles into type reference.” number -1700 from myFiles to reference.
It stops in this part of the code on the on processFilesAndFolders(myFilesOrFolders) handler:

repeat with myFile in my myFiles
						if creator type is "ART5" then
							doExport(myFile as alias) of me
						end if
					end repeat

Saved as an application & double clicking I get this error:
myFiles of <> doesn’t understand the count message

Dropping Illustrator files this error:
Can’t get <> of application “Finder”

Can someone kindly explain me why I’m having all these errors please. I’m using Illustrator CS4. Below the script

property myOutputFolder : ""
property mySuffix : ".EPS"

--To drop files & folders
on open (myFilesOrFolders)
	if myOutputFolder = "" then
		set myOutputFolder to choose folder with prompt "Select a folder to save " & mySuffix & "'s into:"
	end if
	processFilesAndFolders(myFilesOrFolders)
end open

on run
	set myOutputFolder to ""
	set myFolder to choose folder with prompt "Select a folder containing Illustrator files to export as " & mySuffix & ":"
	tell me to open {myFolder}
end run

on processFilesAndFolders(myFilesOrFolders)
	if myOutputFolder ≠ "" then
		repeat with myItem in myFilesOrFolders
			tell application "Finder"
				
				if kind of myItem is "folder" then
					set myFiles to every file of myItem
					
					repeat with myFile in my myFiles
						if creator type is "ART5" then
							doExport(myFile as alias) of me
						end if
					end repeat
					
					set myFolders to every folder of myItem
					tell me to processFilesAndFolders(myFolders)
				else
					if creator type is "ART5" then
						doExport(myItem as alias) of me
					end if
					
				end if
			end tell
		end repeat
	end if
end processFilesAndFolders

on doExport(myExportFile)
	set myFileName to name of (info for myExportFile)
	set myNewFile to (myOutputFolder as string) & myFileName & mySuffix as string
	tell application "Adobe Illustrator"
		open myExportFile
		save document 1 in file myNewFile as eps with options {class:EPS save options, preview:color TIFF, overprint:preserve, embed all fonts:true, embed linked files:false, include document thumbnails:true, compatible gradient printing:false, CMYK PostScript:true, PostScript:level 3}
		close document 1 saving no
	end tell
end doExport

You can’t be guaranteed that a file type or creator exists any more. Since 10.6 file types and creators and sort of being phased out quietly.

I think a bigger issue might be that you need to specifically target “myFile” as the object to compare the file creator. Just because it’s inside the If block doesn’t mean it’s being targeted


else
                   if creator type of myFile is "ART5" then
                       doExport(myItem as alias) of me
                   end if  
               end if