Skip to main content
Inspiring
June 14, 2014
Answered

Script to copy Layer/Group to another Open Document?

  • June 14, 2014
  • 4 replies
  • 10368 views

Hi, I know this topic has been covered many times before. But to clarify, here's what I'm wondering:

Copy the active layer/group to another open document in Photoshop. The simple way is to go to "Layer/Duplicate Layer..." . But this is very tedious. For starters, when you choose that method, and then select the document that you'd like to copy to via the pull-down menu, it successfully copies the layer/group to that document, but it doesn't auto-switch (activate) to the document it was just copied to. You have to hit "Ok", and then manually search through the open documents list via (Window/*choose your document*) to get there. This is a nightmare when you're trying to do this many times.

Here is what I am wondering:

Is it possible to:

a) copy the active layer/group to the clipboard/memory

b) switch to another existing document in Photoshop *via a custom menu* which shows all existing documents

c) once switched to the new existing document, paste that layer/group from the clipboard into that document

..is that possible?

At the very least, are there any scripts that anyone knows of that allows the user to switch between existing documents via a custom menu instead of going to Window/*choose your document* ?

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi @boo radley 2013,

do you mean something like this?

// LayerPaste2anotherDoc.jsx

// https://forums.adobe.com/thread/1496531

// regards pixxxelschubser

var aDoc = app.activeDocument;

var AllDocs = app.documents;

var actLay = aDoc.activeLayer;

if (AllDocs.length > 1) {

var itemDoc = null;

actLay.copy ();

var win = new Window("dialog","Copy the active layer");

this.windowRef = win;

win.Txt1 = win.add ("statictext", undefined, "Paste in which open document?");

win.NewList=win.add ("dropdownlist", undefined, AllDocs);

win.NewList.selection = 0;

itemDoc = win.NewList.selection.index;

win.cancelBtn = win.add("button", undefined, "Abbruch");

win.quitBtn = win.add("button", undefined, "Ok");

win.defaultElement = win.quitBtn;

win.cancelElement = win.cancelBtn;

win.quitBtn.onClick = function() {

win.close();

}

win.NewList.onChange= function () {

    itemDoc = win.NewList.selection.index;

    return itemDoc;

    }

win.show();

app.activeDocument = app.documents[itemDoc];

app.activeDocument.paste();

app.refresh();

} else {

    alert ("No other documents open")

    }

Have fun

4 replies

YaoyongYu
Known Participant
June 15, 2015

mark

copy. script ui

Inspiring
June 15, 2014

sorry guys, i wasn't even aware of the 'correct answer' feature - i'll keep my eyes on it from now on

pixxxelschubser
Community Expert
Community Expert
June 15, 2014

That was not really a problem for me. The explanation is in my other post # 8.

And unfortunately there is no possibility more to mark a post as helpful (since the last Jive update). In my eyes that is very sad.

By the way, does c.fpaffenbichlers script works for you?

Inspiring
June 15, 2014

no, it is giving me the "var idT = charIDToTypeID( "T  " );" error

I use Photoshop CS6

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
June 14, 2014

Hi @boo radley 2013,

do you mean something like this?

// LayerPaste2anotherDoc.jsx

// https://forums.adobe.com/thread/1496531

// regards pixxxelschubser

var aDoc = app.activeDocument;

var AllDocs = app.documents;

var actLay = aDoc.activeLayer;

if (AllDocs.length > 1) {

var itemDoc = null;

actLay.copy ();

var win = new Window("dialog","Copy the active layer");

this.windowRef = win;

win.Txt1 = win.add ("statictext", undefined, "Paste in which open document?");

win.NewList=win.add ("dropdownlist", undefined, AllDocs);

win.NewList.selection = 0;

itemDoc = win.NewList.selection.index;

win.cancelBtn = win.add("button", undefined, "Abbruch");

win.quitBtn = win.add("button", undefined, "Ok");

win.defaultElement = win.quitBtn;

win.cancelElement = win.cancelBtn;

win.quitBtn.onClick = function() {

win.close();

}

win.NewList.onChange= function () {

    itemDoc = win.NewList.selection.index;

    return itemDoc;

    }

win.show();

app.activeDocument = app.documents[itemDoc];

app.activeDocument.paste();

app.refresh();

} else {

    alert ("No other documents open")

    }

Have fun

Inspiring
June 14, 2014

Thats it!! Awesome!!! Totally what I was looking for - this is a very useful script, i hope a lot of people see this one because they will all love it- thank you my friend!!

Inspiring
June 14, 2014

one question though: is there a way to have this script work with both layers *and* groups? Right now it's only working with layers. If not, then maybe have two seperate scripts, one for layers and one for groups?

Inspiring
June 14, 2014

to further simpliy this:

are there any scripts that:

will open up a custom menu, and show a list of all existing documents that are currently loaded into Photoshop. This menu will allow the user to select the document they wish toi switch to, and at the same time copy that document name to the clipboard/memory?