Batch Process Illustrator Files - clitch

Hi all, I have VERY LITTLE AppleScript knowledge but I managed to hack together the below script to change the name of a spot color. It opens all the files in the folder fine, and it changes the name perfectly. But no matter what I try I can’t get the script to close the files after it changes the Spot color. It just leaves them all open. Here’s what I have (minus the closing part)



--folder processing 

on run
	tell me to open {choose folder with prompt "Select a folder to process."}
end run
on open myFinderItems
	repeat with myFinderItem in myFinderItems
		tell application "Finder" to set myItemIsFolder to (kind of myFinderItem = "Folder")
		if myItemIsFolder then
			tell application "Finder" to set myFolderContents to (every item of myFinderItem)
			open myFolderContents
		else
			tell application "Finder" to set myItemExtension to "." & (name extension of myFinderItem) as string
			tell application "Adobe Illustrator 10.0.3"
				open myFinderItem as alias
				set myDocumentName to name of document 1
				set current document to document (myDocumentName as string)
			end tell
			doProcessDocument(myDocumentName)
			
		end if
		
	end repeat
	
	
end open



--Changes name of spot color

on doProcessDocument(myDocumentName)
	
	
	tell application "Adobe Illustrator 10.0.3" to set name of (spots of current document whose name is not "[Registration]" and its color type is spot color) to "E4"
	
	
end doProcessDocument

Yes, I would like to save it. I’d like it to close and save it.

I tried the “close current document saving no” just to see if I could get the script to close all the files but I get an error:

“Expected end of line, etc. but found class name.” and it highlights the word “document”

Any other thoughts?

--folder processing 
on run
	tell me to open {choose folder with prompt "Select a folder to process."}
end run
on open myFinderItems
	repeat with myFinderItem in myFinderItems
		tell application "Finder" to set myItemIsFolder to (kind of myFinderItem = "Folder")
		if myItemIsFolder then
			tell application "Finder" to set myFolderContents to (every item of myFinderItem)
			open myFolderContents
		else
			tell application "Finder" to set myItemExtension to "." & (name extension of myFinderItem) as string
			tell application "Adobe Illustrator 10.0.3"
				open myFinderItem as alias
				set myDocumentName to name of document 1
				set current document to document (myDocumentName as string)
			end tell
			doProcessDocument(myDocumentName)
			close current document saving no
			end if
		end repeat
	end open

--Changes name of spot color

on doProcessDocument(myDocumentName)
	
	tell application "Adobe Illustrator 10.0.3" to set name of (spots of current document whose name is not "[Registration]" and its color type is spot color) to "E4"

end doProcessDocument

clorox,

Your close document statement needs to be inside the “tell Application “Illustrator …”” block.

Are you wanting to save as an eps or standard Illustrator file?

To save as an eps:

choose folder with prompt "Choose folder destination."
set theChoice to result as string
tell application "Adobe Illustrator 10.0.3"
display dialog "Name your file." default answer ""
set fileName to result & ".eps" as string
set savePath to theChoice & fileName
save current document in file savePath as eps with options {class:EPS save options, compatibility:Illustrator 10, preview:color Macintosh, embed linked files:true, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2} with replacing
end tell

to save as Ill file:

choose folder with prompt "Choose folder destination."
set theChoice to result as string
tell application "Adobe Illustrator 10.0.3"
display dialog "Name your file." default answer ""
set fileName to result & ".ai" as string
set savePath to theChoice & fileName
save current document in file savePath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 10} with replacing
end tell

Hope this helps.

PreTech

When I try:


on doProcessDocument(myDocumentName)
    
    tell application "Adobe Illustrator 10.0.3" to set name of (spots of current document whose name is not "[Registration]" and its color type is spot color) to "E4"
    close current document saving no
    
end doProcessDocument

I get the error message: “Expected end of line, etc. but found class name.” and document is highlighted.

If I change the close line to : “close document 1 saving no”. I get the message can’t close while it’s running a script on it.

PreTech,

I’d like to drag a folder full of files onto this script and then have it process everything. So your advice led me to create new folder in the script to save the Converted Files… But it doesn’t matter because I can’t get Illustrator to even close the stinking files.

Here’s what I’ve got so far:


--chooses and creates folders
on run
	
	set folderPath to {choose folder with prompt "Select a destination folder to create folder 'Converted Files'."} as string
	tell application "Finder"
		make new folder at folder folderPath with properties {name:" CONVERTED FILES"}
		set convertedFilesFolder to folder " CONVERTED FILES" of folder folderPath
	end tell
	tell me to open {choose folder with prompt "Select a folder to process."}
	
	
end run

--Folder Processing

on open myFinderItems
	repeat with myFinderItem in myFinderItems
		tell application "Finder" to set myItemIsFolder to (kind of myFinderItem = "Folder")
		if myItemIsFolder then
			tell application "Finder" to set myFolderContents to (every item of myFinderItem)
			open myFolderContents
		else
			tell application "Finder" to set myItemExtension to "." & (name extension of myFinderItem) as string
			tell application "Adobe Illustrator 10.0.3"
				open myFinderItem as alias
				set myDocumentName to name of document 1
				set current document to document (myDocumentName as string)
			end tell
			doProcessDocument(myDocumentName)
			
			
			
		end if
	end repeat
end open

--Changes name of spot color

on doProcessDocument(myDocumentName)
	
	tell application "Adobe Illustrator 10.0.3" to set name of (spots of current document whose name is not "[Registration]" and its color type is spot color) to "E4"
	close current document saving no
	
end doProcessDocument








clorox,

In the line:

it needs to be setup like this:

 tell application "Adobe Illustrator 10.0.3" 
set name of (spots of current document whose name is not "[Registration]" and its color type is spot color) to "E4"
   close current document saving no
end tell

PreTech