Copy link to clipboard
Copied
Hello
In a constant effort to save and place smaller files...I was wondering if there was a way to script illustrator files so that it deletes all the hidden objects.
I end up with so many hiden objects in these files, I am sure that would be a great help, if I could set an action either inside of illustrator or through a script to drag and drop files onto to that would delete the hidden files.
I cannot find any commands on this in the program, so I did not know if it is possible, but I figures I would try.
thanks!
babs
Copy link to clipboard
Copied
Here's a script that I have to delete hidden layers in a file. It could be reworked to target page items. Remember you can only delete something if it is visible.
--get a sourceFolder that holds the files to process
set sourceFolder to (choose folder with prompt "Choose a folder with files to process:") as text
-- get a list of files of the files to process in the sourceFolder
tell application "Finder" to set workingFiles to (every file of folder sourceFolder) as alias list
repeat with aFile in workingFiles
tell application "Adobe Illustrator"
open aFile
set currentFile to front document
tell application "Adobe Illustrator"
set myLayers to every layer of currentFile
repeat with i from 1 to count of items in myLayers
set myLayer to item i of myLayers
set locked of myLayer to false
if visible of myLayer is true then
set visible of myLayer to false
else if visible of myLayer is false then
set visible of myLayer to true
end if
end repeat
delete (every layer of currentFile whose visible is true)
end tell
tell application "Adobe Illustrator"
set visible of (every layer of currentFile) to true
end tell
close currentFile with saving
end tell
end repeat
Copy link to clipboard
Copied
Hi Larry,
This script gives a message that the variable working files is not defined ?
any thoughts on that one 😉
thanks!
babs
Copy link to clipboard
Copied
Where and/or how are you running the script? I just tested it in AICS4 with a folder on my desktop and it worked fine. I had placed the script in the AICS4>Presets>Scripts folder. I just tried it from the script editor and it ran fine from there also.
Copy link to clipboard
Copied
Hi Larry....
Hmmm....I wonder if it has to do with the operating system..
I am on 10.5 on my laptop using AICS3 and it worked fine.
In the Office, we are still on 10.4...I wonder if that is what is causing the problem..
Is that possible?
thanks!!!
babs
Copy link to clipboard
Copied
Shouldn't be a problem. Actually the script was written when I was on 10.4.9 or so. Did you run it from the ScriptEditor at the office or from the application?
Copy link to clipboard
Copied
I actually saved it as an .app on my desktop and double clicked it where it asks me to choose a folder.
Is there another way I should be doing this??
thanks!!!!
babs
Copy link to clipboard
Copied
Try using
Set workingFiles to (every file of folder sourceFolder) as alias list
Copy link to clipboard
Copied
Hi Larry.....
I won't be able to test this till I am back in my other office and that will not be till next wednesday....
I will try it then and let you know if it works 😉
thanks!
babs