Droplet Question Regarding 'On Open' Command

Hi all,

I am trying to write a droplet that when I drop a folder or files onto it it parses them as .AI files and then launches Illustrator 10 and opens all the files I just dropped on.

Once it has done this if does the following code and then exits.

I am having trouble however getting Illustrator 10 to open the fileList which would then allow the rest of my script to work.

If anyone can solve my little problem I would be most appreciative?

The code is as follows:

Thanks in advance,

Dave.

on open fileList
	tell application "Adobe Illustrator 10"
		activate
		
		tell application "Adobe Illustrator 10"
			open fileList
			
			--Get a location for the exported files 
			set targetFolder to choose folder with prompt "Location for exported files"
			
			--Convert the path to a string for later use 
			tell application "Finder" to ¬
				set targetPath to item targetFolder as string
			
			tell application "Adobe Illustrator 10"
				-- Turn off user interaction so dialogs don't cause the script to get stuck 
				set user interaction level to never interact
				
				--Count the open documents 
				set documentCount to count documents
				
				--Export each open document 
				repeat with i from 1 to documentCount
					
					--Get the document's name to use for creating a file path to save to 
					set documentName to name of document i
					
					--	Perform the save
					save document i in file (targetPath & documentName) as eps ¬
						with options {class:EPS save options, compatibility:Illustrator 9, include document thumbnails:true, PostScript:level 3, preview:color Macintosh, embed all fonts:true, CMYK PostScript:true}
				end repeat
			end tell
			
		end tell
	end tell
end open

Hi :slight_smile:

I dont have “Illustrator 10”, but here a small suggestion :

on open fileList
	
	--Get a location for the exported files 
	set targetFolder to choose folder with prompt "Location for exported files"
	
	--Convert the path to a string for later use 
	set targetPath to item targetFolder as string
	
	tell application "Adobe Illustrator® 9.0"
		activate
		
		-- Turn off user interaction so dialogs don't cause the script to get stuck 
		set user interaction level to never interact 
		
		--Repeat for each item in "fileList"
		repeat with AiDoc in fileList
			
			--Open document "AiDoc"
			open AiDoc
			
			--Get the document's name to use for creating a file path to save to 
			set AiDocName to name of document 1
			
			--Perform the save 
			save document AiDocName in file (targetPath & AiDocName) as eps ¬ 
			   with options {class:EPS save options, compatibility:Illustrator 9, ¬
			   include document thumbnails:true, PostScript:level 3, ¬
			   preview:color Macintosh, embed all fonts:true, CMYK PostScript:true} 
		end repeat

		-- Turn ON user interaction (but i dont know the correct syntax)
		--set user interaction level to interact ???

	end tell
end open

:wink:

Hey Fredo,

Thanks for the speedy reply.

After I compiled your script I tried to run it however I get an error on this line:


   --Convert the path to a string for later use 
   set targetPath to item targetFolder as string 

After I choose a folder on the desktop I recieve an error saying cant make some expected data into the type string.

Any ideas?

Thanks again,

Dave

Hi :slight_smile:

Ho sorry, the correct syntax is :

set targetPath to targetFolder as string

Without word “item”…

:wink:

Hey Fredo thanks for being so helpful I just have one last request if you are ok with it :slight_smile:

Currently I have 100 or so files I wish to do this with. The script works perfectly and I thank you for it but because it opens all the files in fileList that means that the RAM usage for Illustrator goes through the roof!

Do you any way in which I could re-write the script that for each item in fileList it opens them individually, then saves it, closes it and moves onto the next item in the fileList?

This is my final hurdle, and I appreciate your assistance in this matter. Just opening up and previewing 100 + files I think will make Illustrator have a heart attack :smiley:

Thanks again Fredo,

Dave

Hi Dave :slight_smile:

There is certainly a confusion.

In your proposal, there is this instruction:

--open every document
open fileList

In this case, Illustrator opens all the documents of the list,
what can cause slownesses following a saturation of the memory.

But, in my suggestion, the loop is carried out by opening
and saving each document individually:

--Repeat for each item in "fileList" 
repeat with AiDoc in fileList 
--Open document "AiDoc" 
open AiDoc 

Perhaps that us should close each document by adding
an additional instruction.
Here, the whole structure of the loop:

--Repeat for each item in "fileList" 
repeat with AiDoc in fileList 
          
  --Open document "AiDoc" 
  open AiDoc 
          
  --Get the document's name to use for creating a file path to save to  
  set AiDocName to name of document 1 
          
  --Perform the save  
  save document AiDocName in file (targetPath & AiDocName) as eps ¬  
    with options {class:EPS save options, compatibility:Illustrator 9, ¬ 
    include document thumbnails:true, PostScript:level 3, ¬ 
    preview:color Macintosh, embed all fonts:true, CMYK PostScript:true} 

  --Close document
  close document AiDocName
end repeat 

I do not know if it is the best way of completing this work
(I dont have Illustrator 10 to make tests), but I think that code can go now.

Sorry for my rudimentary English, I am French and does not speak
your language very well. Thank you for your indulgence.

:rolleyes:

Hey,

Thanks Fredo you just solved my problem :smiley: Thanks very much!

Je ne parle pas francais bien, mais…
“Merci beaucoup pour votre aide”

Thanks,

Dave

Could you post the final script. I think it is what I am looking for.

Thanks, Jim

I believe the script works as it was first posted by Fredo on Sat Mar 01… with the exception that it should read:


         --Convert the path to a string for later use 
         tell application "Finder" to ¬ 
            set targetPath to targetFolder as string 

Note the exclusion of the word item