Hi everyone
I’ve made this AS: it works fine with a single file, but give me an error with two or more file
Error “can’t get document 2 of Adobe Illustrator”
Here you are the script
on run
set these_items to choose file with prompt "File/s" with multiple selections allowed without invisibles
process_item(these_items)
end run
on open these_items
process_item(these_items)
end open
on process_item(these_items)
set targetFolder to choose folder with prompt "Location for exported files"
set targetPath to (targetFolder as Unicode text)
-- Heart of the script!
tell application "Adobe Illustrator"
set user interaction level to never interact
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
open this_item
set documentName to name of document i
save document i in file (targetPath & documentName) as Illustrator with replace
close document i saving no
end repeat
end tell
end process_item
your script always processes one file at the same time.
Therefore there’s never a second document
try this for the repeat loop:
repeat with this_item in these_items
open this_item
set documentName to name of document 1
save document 1 in file (targetPath & documentName) as Illustrator with replace
close document 1 saving no
end repeat
Lot of compliments Stefank. Your script works well.
But I don’t undestand where is my error.
My script opened first file, process and close it. Then open the second file (this is right) and then give me the error.
the variable i is right (the second file was open fine) and also the variable this_item I think.
Why you say that the script “always processes one file at the same time”.
Thx for your patience, Stefank, but I have a lot of things to learn in AppleScript…
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.2pre) Gecko/20070107 Camino/1.1a2
Operating System: Mac OS X (10.4)
You open each file by filename, not by number, and you close it before opening the next one.
So there is only one open document in Illustrator at the same time, which is always document 1