Script to select all images on artboard
Copy link to clipboard
Copied
Hi all
I have an artboard that contian images and shapes around it
I need script that select all images , move them ( cut ) to a new layer , shapes around images in move to another layer without images
Thanks
Explore related tutorials & articles
Copy link to clipboard
Copied
var doc = app.activeDocument;
doc.layers.add().name = "Images";
doc.layers.add().name = "Linked Files";
doc.layers.add().name = "Other";
for (var i = 0; i < doc.pageItems.length; i++) {
if (doc.pageItems[i].typename == "RasterItem") {
move(doc.pageItems[i], doc.layers["Images"]);
} else if (doc.pageItems[i].typename == "PlacedItem") {
move(doc.pageItems[i], doc.layers["Linked Files"]);
} else {
move(doc.pageItems[i], doc.layers["Other"]);
}
}
function move(what, where) {
what.move(where, ElementPlacement.PLACEATEND);
}
Copy link to clipboard
Copied
Thanks for Your reply
But the script work on some images and some images not work
Ex : I want all images move to layer 1 without its frames
all frames move to layer 2 without images
Here is the pdf file open it in illustrator
Copy link to clipboard
Copied
A little side note:
The script from @femkeblanco works exactly as you described. Unfortunately, you forgot to mention that there are dozens of nested clipping groups in your file and furthermore compound path items in some groups exists.
It might also be helpful to specify the correct Illustrator version. Because not every helper here in the forum always uses the latest version.
Copy link to clipboard
Copied
Thanks For your Reply
You are correct , I forgot to mention that there are dozens of nested clipping groups in your file and furthermore compound path items in some groups exists.
What is the script in this case ?
I use illustrator 2023

