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

Photosho Layers choosing

Community Beginner ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Hi,

 

I am working on mockups which contains more that 100 or 200 layers. When I shifting the layers I have to do it manually, Can we have any smart sollution that I can shift it automatically.

 

or my suggestion is can we make a programming that helps me to slect the (1st) layer what I choosen and the other layer (2nd layer name) and  shift it mannually

 

Thank you

TOPICS
Windows

Views

202

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
Adobe
Community Expert ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Could you please explain what you actually mean and post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible? 

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 Beginner ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Hi

Thank You for replying, I am stating you the exact problem what I am facing is
When I am working on a webpage mockup, I created lots of layers means 1 (one) layer to 200 layers where I need to move 22nd layer close to 150th layer. In that case I am doing manually as selecting the 22nd layer and by pressing shift + Bracket button to Down the layer.

 

Can we do this like select the 22nd layer comand it to move under the layer no 15th (like find and replace style)

 

Thank you

Prasantaadobe.jpg

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 ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

prasanta.99u@gmail.com 

 

Will you use layer groups/sets, or only regular/standard "top-level" layers of various kinds (pixel layers, type layers, fill layers, shape layers, adjustment layers etc) as per your screenshot? Layer groups are useful, however, they can complicate scripting.

 

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Please provide before/after screenshots to clearly illustrate your post, it is not clear and is likely lost in translation (what do you mean by shift).

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Aside from what the actual task is it also might bear clarification if only two Layers are involved or a greater number might be selected. 

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 ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

The following script works with top-level layers:

 

Change Active Layer Order.png

Keep in mind that layer index numbers are ordered/numbered from the bottom of the layer panel upwards, starting at zero. Example:

 

Layer 5            [5]

Layer 4            [4]

Layer 3            [3]

Layer 2            [2]

Layer 1            [1]

Background     [0]

 

Therefore, to move Layer 1 above Layer 3, one would enter: 4

 

Layer 5

Layer 4

Layer 1

Layer 3

Layer 2

Background

 

/*
Change Active Layer Order.jsx
v1.0, 17th July 2022, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/photosho-layers-choosing/td-p/13070937
*/

#target photoshop

while (isNaN(theInput = prompt("Change Active Layer Order v1.0" + "\n" + "Move the active layer to position no.:", "")));
var indexNumber = parseInt(theInput);

moveLayerInStack(indexNumber);

function moveLayerInStack(moveTo) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putIndex( s2t( "layer" ), moveTo );
	descriptor.putReference( s2t( "to" ), reference2 );
	descriptor.putBoolean( s2t( "adjustment" ), false );
	descriptor.putInteger( s2t( "version" ), 5 );
	list.putInteger( 2 );
	descriptor.putList( s2t( "layerID" ), list );
	executeAction( s2t( "move" ), descriptor, DialogModes.NO );
}

 

If you had unique layer names, then moving the active layer based on the name might be more intuitive (the following script is not for layers nested inside layer groups, it is only for top-level layers/layer groups):

 

#target photoshop
// Top-level layers only, doesn't search inside layer groups
var lyrName = prompt("Move Active Layer Order by Name v1.0" + "\n" + "Move active layer above layer name:", "")
var sourceLayer = activeDocument.activeLayer;
var destinationLayer = activeDocument.layers.getByName(lyrName);
sourceLayer.move(destinationLayer, ElementPlacement.PLACEBEFORE);

 

Finding and moving layers inside layer groups is discussed here:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/getbyname-option-not-working-if-layer...

 

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 ,
Jul 17, 2022 Jul 17, 2022

Copy link to clipboard

Copied

LATEST

Could you give this a try? 

moveLayersTogetherInStackScr.gif

// move selected layers beneath the topmost of the selected layers;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
var theSelected = collectSelectedLayersIdAndIndex();
if (theSelected.length > 1) {
theSelected.sort(sortArrayByIndexedItem);
var theTargetID = theSelected[theSelected.length-1][2]-1;
for (var m  = 0; m < theSelected.length - 1; m++) {
	moveLayerInStack(theTargetID, theSelected[m][1])
};
}
};
////////////////////////////////////
////// based on code by stephen a march //////
function moveLayerInStack(moveTo, theID) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putIdentifier( s2t( "layer" ), theID);
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putIndex( s2t( "layer" ), moveTo );
	descriptor.putReference( s2t( "to" ), reference2 );
	descriptor.putBoolean( s2t( "adjustment" ), false );
	descriptor.putInteger( s2t( "version" ), 5 );
	list.putInteger( 2 );
	descriptor.putList( s2t( "layerID" ), list );
	executeAction( s2t( "move" ), descriptor, DialogModes.NO );
};
////// collect id and index of selected layers //////
function collectSelectedLayersIdAndIndex () {
// get selected layers;
	var selectedLayers = new Array;
	var ref = new ActionReference();
	ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
	var desc = executeActionGet(ref);
	if (desc.getBoolean(stringIDToTypeID("hasBackgroundLayer")) == true) {var theAdd =0}
	else {var theAdd = 1};
	if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
	desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
	var c = desc.count;
	var selectedLayers = new Array();
// run through selected layers;
	for(var i=0;i<c;i++){
	var theIndex = desc.getReference( i ).getIndex()+theAdd;
// get id for solid color layers;
	try {
	var ref = new ActionReference();
	ref.putIndex( charIDToTypeID("Lyr "), theIndex ); 
	var layerDesc = executeActionGet(ref);
	var theName = layerDesc.getString(stringIDToTypeID('name'));
	var theIdentifier = layerDesc.getInteger(stringIDToTypeID ("layerID"));
	var theIndex = layerDesc.getInteger(stringIDToTypeID ("itemIndex"));
	selectedLayers.push([theName, theIdentifier, theIndex]);
	} catch (e) {};
	};
// if only one:
	}else{
	var ref = new ActionReference();
	ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
	var layerDesc = executeActionGet(ref);
	try {
	var theName = layerDesc.getString(stringIDToTypeID('name'));
	var theIdentifier = layerDesc.getInteger(stringIDToTypeID ("layerID"));
	var theIndex = layerDesc.getInteger(stringIDToTypeID ("itemIndex"));
	selectedLayers = [[theName, theIdentifier, theIndex]]
	} catch (e) {};
	};
	return selectedLayers
};
////// sort a double array, thanks to sam, http://www.rhinocerus.net/forum/lang-javascript/ //////
function sortArrayByIndexedItem(a,b) {
	var theIndex = 2;
	if (a[theIndex]<b[theIndex]) return -1;
	if (a[theIndex]>b[theIndex]) return 1;
	return 0;
	};
////// based on code by mike hale, via paul riggott //////
function selectLayerByID(id,add){ 
    add = undefined ? add = false:add 
    var ref = new ActionReference();
        ref.putIdentifier(charIDToTypeID("Lyr "), id);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref );
           if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) ); 
          desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
       try{
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
    }catch(e){
    alert(e.message); 
    }
    };


 

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