• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
5

Indesign script to copy selected items to a new page in another document

Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I have been given a document with 150 pages and I need to copy some elements from some pages into another document, they need to go into separate pages.

Does anybody know if there is a script to do that?

 

In an ideal world it would operate something like like this:

1-select objects in document 1

2-shortcut to run script

3-script copies to document 2

4-and if there are items existing on the page

5-creates a new page and pastes the items.

 

if point 4 not possible, it would just skip and go to step 5.

Any suggestions welcome, thanks.

TOPICS
Scripting

Views

738

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 23, 2023 Sep 23, 2023

Hi @A27300849wzxk ,

if you are working with two documents open, the active document is the one where you selected the items, the other one is the one you like to paste the selected items to, it could go like that:

 

// CopyPasteSelectedItemsToDifferentDoc-v1.jsx

// Copy selected items to the clipboard:
app.copy();

// Switch to the other document, the target document, if only two documents are open:
app.activeDocument = app.documents[1];

// Test if the spread of the target document is empty.
/
...

Votes

Translate

Translate
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

You don't really need script for that...

 

  1. select elements in DOC-1
  2. CTRL+C
  3. CTRL+TAB - switch to DOC-2
  4. if you see something on a page - add new page (*)
  5. CTRL+V
  6. CTRL+TAB - switch to DOC-1
  7. SHIFT+PageDown - go to next page
  8. goto step 1.

 

(*) - you can set a shortcut for adding new PAGE:

RobertTkaczyk_0-1695474693629.png

I've assigned "Numpad 9"

 

It would be much easier if you were working on a PC - you could use my ID-Tasker - even free version could do this...

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Thank you very much for your reply Robert, I have been doing something similar to your suggestion with previous documents. That is, manually copying and pasting between documents.

I am trying to reduce the amount of copy/paste and jumping between documents, hence thinking that there might be a script that does something similar and that I could assign a shortcut.

The main issue is that first I have to select some, but not all the items in the page of Doc 1, then copy to a new page in  Doc 2...

Unfortunatelly cannot try ID-Tasker, as I am on a Mac... But thaks for the suggestion!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Hi @A27300849wzxk ,

how do you know what items must be copied over?

If there is an easy algorithm for this, a script could duplicate all of the items in one run.

 

An algorithm, perhaps like copy all items on a given layer in a particular range of pages.

Or, copy all text frames. Or, copy all items with fill color "blabalaba". Something like that…

Or a combination of the above. A rule or a set of rules what is to copy over.

 

On the other hand, it takes a lot more time to formulate the algorithm, to write and finally to test a script than to do it the "manual" way. At least most of the time.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I'm pretty sure OP needs to automate the copy&paste part only - copy selection to new document -> with checking if page is empty -> and create new page if not empty -> then paste -> and go back to first document.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Thanks for your reply Uwe, all items to be copied must be selected manually, depending on the page might be text boxes, picture boxes, rectangles, etc. So there is no "standard" items.

The amount of layers and names vary from document to document, which makes it a little bit more complicated.

I have already done a few of these documents manually, but I will have to do a new batch in the future, hence trying to find something that would allow me to select a bunch of objects in a page of Doc 1, and with a shorcut trigger a script that would do the rest (copy, jump to other Doc, create new page and paste).

I thought that maybe there was already something, or maybe I could tweak an existing script to to do that. But maybe will have to carry on manually.

Thanks.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

I'm not JS guy so can't give you exact code - beside algorithm - but I'm pretty sure @m1b or @rob day or @Peter Kahrel or others can create it on the spot.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

@A27300849wzxk said: "… Thanks for your reply Uwe, all items to be copied must be selected manually, depending on the page might be text boxes, picture boxes, rectangles, etc. So there is no "standard" items."

 

Hm. One rule could also be "copy all items from that page".

Apart from that a script can actually work on selected items.

It can use the menu commands that currently are available ( not grayed out ) or it can use other methods.

 

Do you copy from a facing pages document to another facing pages document?

Or do you copy from a document with one page per spread to another document with one page per spread?

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied


Do you copy from a facing pages document to another facing pages document?

Or do you copy from a document with one page per spread to another document with one page per spread?

Thanks, Uwe, the documents I copy from are spreads and single pages (and different sizes) and the document I copy to is setup as single pages.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

Hi @A27300849wzxk ,

if you are working with two documents open, the active document is the one where you selected the items, the other one is the one you like to paste the selected items to, it could go like that:

 

// CopyPasteSelectedItemsToDifferentDoc-v1.jsx

// Copy selected items to the clipboard:
app.copy();

// Switch to the other document, the target document, if only two documents are open:
app.activeDocument = app.documents[1];

// Test if the spread of the target document is empty.
// Add a spread
// Make it the active one
var currentSpread = app.layoutWindows[0].activeSpread;
if( currentSpread.pageItems.length > 0 )
{
	var nextSpread = app.activeDocument.spreads.add();
	app.layoutWindows[0].activeSpread = nextSpread;
};

// Paste the contents of the clipboard to the active spread of the target document:
app.paste();

// To switch back to the source document:
app.activeDocument = app.documents[1];

 

That would work best if both documents are working with none-facing pages where every spread has only one single page and no elements are on the pasteboard. The script would add a new spread at the end of the target document when a selectable item is on the spread.

 

The code will get more complicated if you are using facing pages documents.

Instead of the line app.paste() one could also use app.pasteInPlace() if you want to maintain the relative position of the copied objects according to the source document.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2023 Sep 23, 2023

Copy link to clipboard

Copied

LATEST

Brilliant! Thanks Uwe, this is exactly what I was after. Works perfect, and it is so quick. It will save me bags of time.

Thank you for your solution!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines