Skip to main content
Berezin_Illustrator
Known Participant
November 22, 2020
Question

Collect objects from different files to one

  • November 22, 2020
  • 1 reply
  • 741 views

Hi guys

I need the script to collect objects from different files to one

1.I have a folder with Ai* files whicj namedlike 1,2,3,4...

2. Ineed to copy сontent from each files to one document to different layers whicn named like 1.2.3.4.5. or something like this.

It will be enough if script execute command "select all" - "copy"- "Paste" . The main goal is collect objects from different files to one.

And one small detail. I do not know Java.
I have small budget if needed.

This topic has been closed for replies.

1 reply

femkeblanco
Legend
November 22, 2020
// "copy-n-paste" pageItems
// from open docs named 1, 2, 3, ... , n
// to corresponding layers in new untitled doc
var docs = app.documents;
var docNames = [];
for (var i = 0; i < docs.length; i++) {
  docNames.push(docs[i].name);
  docNames.sort();
}
var targetDoc = app.documents.add();
for (var i = docNames.length - 1; i > -1; i--) {
  docs[docNames[i]].activate();
  var layer1 = targetDoc.layers.add();
  layer1.name = docNames[i];
  for (var j = 0; j < app.activeDocument.pageItems.length; j ++) {
    app.activeDocument.pageItems[j].duplicate(targetDoc.layers[docNames[i]]);
  }
}
Berezin_Illustrator
Known Participant
November 22, 2020

It is good. Thank you a lot.

But I have some trouble with copied some objects. Please check my screenshots.

The first is my source file. The second is file after processing by script.

All select layers are copies.

 

P.S. I think it is my trouble and I should give your more information about files?

 

 

Berezin_Illustrator
Known Participant
November 22, 2020

Sorry. It really works with more clearly files