Copy link to clipboard
Copied
I Wish Select All Layer One By One Sequentially. Like 1,2,3,4 so on.
Thanks in Advance
Presuming that a layer has a unique name (otherwise the first layer with the name will be targeted, which may not be the one you require):
var selectLayer1 = app.activeDocument.artLayers.getByName("Layer 1");
app.activeDocument.activeLayer = selectLayer1;
or
app.activeDocument.activeLayer = app.activeDocument.layers["Layer 1"];
The layers collection can also be used, it starts the indexing at zero, so the 8th layer from the top would be #7:
var selectLayer = app.activeDocum
...
In your script, right after the line
var ids = getLayersIDs (); // getting ids of selected layers
paste this code:
ids.sort(cmp);
function cmp(a, b)
{
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), a);
var b1 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l1 = b1.getUnitDoubleValue(stringIDToTypeID("left"));
...
Your first screen shot showed that you wanted the artboard numbered top to bottom then left to right, which the previous script that I posted did. You're second screen shot shows left to right then top to bottom. So this script does that:
#target photoshop
var doc = activeDocument;
var artArray = [];
var count = 0;
for(var i=0;i<doc.layers.length;i++){
doc.activeLayer = doc.layers[i];
if(isArtBoard ()){
var dimArt = getArtboardDimensions ()
artArray.push([dimArt[0],dimA
...
Copy link to clipboard
Copied
Wow! There's 3rd one same thread? What a mess. If you're moderator combine them into one.
Copy link to clipboard
Copied
Hello Everyone I found the script From MXKS, But I need modify the script. Anyone could you help me. I am new Of PS Script. I have seached on google but can't find.
The Script was created By @r-bin, I need Serial Number wise to Layers. For Better Understand I posted the image.
If I am say something wrong, extremly sorry because i am new here..
Here is script For Serial Number Wise Layers
var newName = "Layer";
var ids = getLayersIDs(); // getting ids of selected layers
ids.sort(cmp);
function cmp(a, b)
{
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), a);
var b1 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l1 = b1.getUnitDoubleValue(stringIDToTypeID("left"));
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), b);
var b2 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l2 = b2.getUnitDoubleValue(stringIDToTypeID("left"));
return l1 > l2;
}
catch (e) { throw(e); }
}
//for each id in the list
for (var i = 0; i < ids.length; i++)
{
// select the layer first (well, artboard in this case)
selectById(ids[i]);
//rename it to "my name 1", "my name 2", etc
activeDocument.activeLayer.name = newName + " " + (i + 1);
}
// this will get IDs of selected layers/groups/artboards
function getLayersIDs()
{
var lyrs = [];
var lyr;
var ref = new ActionReference();
var desc;
var tempIndex;
var ref2;
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("targetLayers"));
ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var targetLayers = executeActionGet(ref).getList(stringIDToTypeID("targetLayers"));
for (var i = 0; i < targetLayers.count; i++)
{
tempIndex = 0;
ref2 = new ActionReference();
try
{
activeDocument.backgroundLayer;
ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex());
try
{
desc = executeActionGet(ref2);
tempIndex = desc.getInteger(stringIDToTypeID("itemIndex")) - 1;
}
catch (e)
{
tempIndex = 0;
}
}
catch (o)
{
ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex() + 1);
desc = executeActionGet(ref2);
tempIndex = desc.getInteger(stringIDToTypeID("itemIndex"));
}
lyrs.push(desc.getInteger(stringIDToTypeID("layerID")));
}
return lyrs;
};
// this will select a layer by ID
function selectById(id)
{
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIdentifier(charIDToTypeID('Lyr '), id);
desc1.putReference(charIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
};
Anyone can't reply i can't resove my problem
Copy link to clipboard
Copied
Anyone can't reply i can't resove my problem
By @Sriya69
Copy link to clipboard
Copied
Sorry, I have not seen original code, However I run the script in PS (But It's not perfect) ....
For Example I have attached the image ------
I am trying to Serial Number of layer in my own templates.. Original Code have instead of return l1 - l2;
My Problem is Seial Number wise Layer in my own templates, Here is posted 2images.
Could you compare the image 1 and image 2 For Better Understand..
Image 2
Original Code is Here
var newName = "Layer";
var ids = getLayersIDs(); // getting ids of selected layers
ids.sort(cmp);
function cmp(a, b)
{
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), a);
var b1 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l1 = b1.getUnitDoubleValue(stringIDToTypeID("left"));
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), b);
var b2 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l2 = b2.getUnitDoubleValue(stringIDToTypeID("left"));
return l1 - l2;
}
catch (e) { throw(e); }
}
//for each id in the list
for (var i = 0; i < ids.length; i++)
{
// select the layer first (well, artboard in this case)
selectById(ids[i]);
//rename it to "my name 1", "my name 2", etc
activeDocument.activeLayer.name = newName + " " + (i + 1);
}
// this will get IDs of selected layers/groups/artboards
function getLayersIDs()
{
var lyrs = [];
var lyr;
var ref = new ActionReference();
var desc;
var tempIndex;
var ref2;
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("targetLayers"));
ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var targetLayers = executeActionGet(ref).getList(stringIDToTypeID("targetLayers"));
for (var i = 0; i < targetLayers.count; i++)
{
tempIndex = 0;
ref2 = new ActionReference();
try
{
activeDocument.backgroundLayer;
ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex());
try
{
desc = executeActionGet(ref2);
tempIndex = desc.getInteger(stringIDToTypeID("itemIndex")) - 1;
}
catch (e)
{
tempIndex = 0;
}
}
catch (o)
{
ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex() + 1);
desc = executeActionGet(ref2);
tempIndex = desc.getInteger(stringIDToTypeID("itemIndex"));
}
lyrs.push(desc.getInteger(stringIDToTypeID("layerID")));
}
return lyrs;
};
// this will select a layer by ID
function selectById(id)
{
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIdentifier(charIDToTypeID('Lyr '), id);
desc1.putReference(charIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
};
Copy link to clipboard
Copied
....
By @Sriya69
OK. Try using this comparison function.
function cmp(a, b)
{
try {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
ref.putIdentifier(stringIDToTypeID("layer"), a);
var bn = executeActionGet(ref).getObjectValue(stringIDToTypeID("bounds"));
var l1 = bn.getUnitDoubleValue(stringIDToTypeID("left"));
var r1 = bn.getUnitDoubleValue(stringIDToTypeID("right"))
var t1 = bn.getUnitDoubleValue(stringIDToTypeID("top"));
var b1 = bn.getUnitDoubleValue(stringIDToTypeID("bottom"))
var x1 = (r1+l1)/2;
var y1 = (b1+t1)/2;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
ref.putIdentifier(stringIDToTypeID("layer"), b);
var bn = executeActionGet(ref).getObjectValue(stringIDToTypeID("bounds"));
var l2 = bn.getUnitDoubleValue(stringIDToTypeID("left"));
var r2 = bn.getUnitDoubleValue(stringIDToTypeID("right"))
var t2 = bn.getUnitDoubleValue(stringIDToTypeID("top"));
var b2 = bn.getUnitDoubleValue(stringIDToTypeID("bottom"))
var x2 = (r2+l2)/2;
var y2 = (b2+t2)/2;
var l = l1>l2?l1:l2;
var r = r1<r2?r1:r2;
if (x1 >= l && x1 <= r && x2 >= l && x2 <= r ) // same column, i.e. through the layers you can spend a vertical direct
{
return y1 - y2;
}
else
{
return x1 - x2;
}
}
catch (e) { throw(e); }
}
Copy link to clipboard
Copied
Thanku so much this is perfect working siir ( You have modify the function)
Copy link to clipboard
Copied
This script is doing less new in Photoshop C3, is this script possible and will reduce it in CS3 ?
Copy link to clipboard
Copied
unecessary redirect to another thread removed.
Copy link to clipboard
Copied
EDIT: 21st June 2025:
I have updated my "Active Layer Inspector" script to v1.9:
/*
Active Layer Inspector.jsx
Stephen Marsh
v1.9 - 21st June 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/could-you-select-all-layers-sequentially/td-p/11732510/page/3#U12078337
https://gist.githubusercontent.com/MarshySwamp/ef345ef3dec60a843465347ee6fcae2f/raw/3f4ebef778bbc841f5c27f2744b79b6044145fbc/Active%2520Layer%2520Inspector.jsx
Displays info about the current layer, useful for script development and debugging
Related script for all layers:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-copy-multiple-layer-names/m-p/13118781#U15263262
*/
// name = Not unique
// itemIndex = Changes with layer addition/removal, Background layer index starts at 0 - no Background starts at 1
// layer.id = Unique, static and more useful
// Bounds:
// + - - - - - - - [1] - - - - - - - +
// | |
// | |
// [0] [2]
// | |
// | |
// + - - - - - - - [3] - - - - - - - +
#target photoshop
// Save the original ruler units to restore later
var originalRulerUnits = app.preferences.rulerUnits;
// Set the ruler units to pixels
app.preferences.rulerUnits = Units.PIXELS;
// Check if there are open documents
if (app.documents.length === 0) {
alert('Please open a document before running this script!');
app.preferences.rulerUnits = originalRulerUnits;
exit();
}
// Create the main window
var dlg = new Window('dialog', 'Active Layer Inspector (v1.9)');
dlg.orientation = 'column';
dlg.alignChildren = 'fill';
dlg.preferredSize.width = 470;
// Panel/Group for layer properties selection
var layerPropertiesPanel = dlg.add('panel', undefined, 'Select Layer Properties to Display:');
layerPropertiesPanel.orientation = 'column';
layerPropertiesPanel.alignChildren = 'left';
// Create layer properties selection checkboxes
var layerNameCB = layerPropertiesPanel.add('checkbox', undefined, 'Layer Name');
var visibilityCB = layerPropertiesPanel.add('checkbox', undefined, 'Visibility');
var typeCB = layerPropertiesPanel.add('checkbox', undefined, 'Type');
var layerKindCB = layerPropertiesPanel.add('checkbox', undefined, 'Kind (DOM)');
var layerKindAMCB = layerPropertiesPanel.add('checkbox', undefined, 'Kind (AM)');
var opacityCB = layerPropertiesPanel.add('checkbox', undefined, 'Opacity');
var blendModeCB = layerPropertiesPanel.add('checkbox', undefined, 'Blend Mode');
var maskCB = layerPropertiesPanel.add('checkbox', undefined, 'Mask');
var layerIdCB = layerPropertiesPanel.add('checkbox', undefined, 'Layer ID');
var parentCB = layerPropertiesPanel.add('checkbox', undefined, 'Parent');
// Create position & dimension checkboxes in a sub-panel
var dimensionPanel = layerPropertiesPanel.add('panel', undefined, 'Position & Dimensions:');
dimensionPanel.orientation = 'column';
dimensionPanel.alignChildren = 'left';
var upperLeftXCB = dimensionPanel.add('checkbox', undefined, 'Upper Left X');
var upperLeftYCB = dimensionPanel.add('checkbox', undefined, 'Upper Left Y');
var widthCB = dimensionPanel.add('checkbox', undefined, 'Width');
var heightCB = dimensionPanel.add('checkbox', undefined, 'Height');
// Check all checkboxes by default
layerNameCB.value = true;
visibilityCB.value = true;
typeCB.value = true;
layerKindCB.value = true;
layerKindAMCB.value = true;
opacityCB.value = true;
blendModeCB.value = true;
maskCB.value = true;
layerIdCB.value = true;
parentCB.value = true;
upperLeftXCB.value = true;
upperLeftYCB.value = true;
widthCB.value = true;
heightCB.value = true;
// Button to select/deselect all columns
var selectAllGroup = layerPropertiesPanel.add('group');
selectAllGroup.orientation = 'row';
var selectAllButton = selectAllGroup.add('button', undefined, 'Select All');
var deselectAllButton = selectAllGroup.add('button', undefined, 'Deselect All');
selectAllButton.onClick = function () {
layerNameCB.value = true;
visibilityCB.value = true;
typeCB.value = true;
layerKindCB.value = true;
layerKindAMCB.value = true;
opacityCB.value = true;
blendModeCB.value = true;
maskCB.value = true;
layerIdCB.value = true;
parentCB.value = true;
upperLeftXCB.value = true;
upperLeftYCB.value = true;
widthCB.value = true;
heightCB.value = true;
};
deselectAllButton.onClick = function () {
layerNameCB.value = false;
visibilityCB.value = false;
typeCB.value = false;
layerKindCB.value = false;
layerKindAMCB.value = false;
opacityCB.value = false;
blendModeCB.value = false;
maskCB.value = false;
layerIdCB.value = false;
parentCB.value = false;
upperLeftXCB.value = false;
upperLeftYCB.value = false;
widthCB.value = false;
heightCB.value = false;
};
// Cancel and OK buttons
var buttonGroup = dlg.add('group');
buttonGroup.orientation = 'row';
buttonGroup.alignment = 'right';
var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
var okButton = buttonGroup.add('button', undefined, 'OK');
okButton.onClick = function () {
if (!app.documents.length) {
alert('There are no documents open!');
return;
}
var activeLayer = app.activeDocument.activeLayer;
// Create array of selected columns/properties and their labels
var columns = [];
var columnProperties = [];
if (layerNameCB.value) { columns.push("Layer Name"); columnProperties.push("layerName"); }
if (visibilityCB.value) { columns.push("Visibility"); columnProperties.push("visibility"); }
if (typeCB.value) { columns.push("Type"); columnProperties.push("type"); }
if (layerKindCB.value) { columns.push("Kind (DOM)"); columnProperties.push("layerKind"); }
if (layerKindAMCB.value) { columns.push("Kind (AM)"); columnProperties.push("layerKindAM"); }
if (opacityCB.value) { columns.push("Opacity"); columnProperties.push("opacity"); }
if (blendModeCB.value) { columns.push("Blend Mode"); columnProperties.push("blendMode"); }
if (maskCB.value) { columns.push("Mask"); columnProperties.push("hasMask"); }
if (layerIdCB.value) { columns.push("Layer ID"); columnProperties.push("layerId"); }
if (parentCB.value) { columns.push("Parent"); columnProperties.push("parent"); }
if (upperLeftXCB.value) { columns.push("Upper Left X"); columnProperties.push("upperLeftX"); }
if (upperLeftYCB.value) { columns.push("Upper Left Y"); columnProperties.push("upperLeftY"); }
if (widthCB.value) { columns.push("Width"); columnProperties.push("width"); }
if (heightCB.value) { columns.push("Height"); columnProperties.push("height"); }
// At least one column must be selected
if (columns.length === 0) {
alert('Please select at least one property to display.');
return;
}
// Collect active layer info
var info = getActiveLayerInfo(activeLayer, columnProperties);
// Prepare alert string
var result = "Active Layer Info:\n";
for (var i = 0; i < columns.length; i++) {
result += columns[i] + ": " + info[i] + "\n";
}
alert(result);
dlg.close();
};
cancelButton.onClick = function () {
dlg.close();
};
dlg.center();
dlg.show();
// Restore original ruler units
app.preferences.rulerUnits = originalRulerUnits;
// Helper: get info for the active layer
function getActiveLayerInfo(layer, columnProperties) {
// Parent name
var parent = "";
try {
if (layer.parent && layer.parent.typename === "LayerSet") {
parent = layer.parent.name;
}
} catch (e) { parent = ""; }
var isAdjustment = isAdjustmentLayer(layer);
var type = layer.typename;
// Default position/dimensions
var upperLeftX = "";
var upperLeftY = "";
var width = "";
var height = "";
// For groups & adjustment layers, leave width and height empty
if (type !== "LayerSet" && !isAdjustment) {
if (layer.isBackgroundLayer) {
upperLeftX = 0;
upperLeftY = 0;
var bounds = layer.bounds;
width = parseInt(bounds[2] - bounds[0]);
height = parseInt(bounds[3] - bounds[1]);
} else {
var bounds = layer.bounds;
upperLeftX = parseInt(bounds[0]);
upperLeftY = parseInt(bounds[1]);
width = parseInt(bounds[2] - bounds[0]);
height = parseInt(bounds[3] - bounds[1]);
if (upperLeftX === 0) upperLeftX = "";
if (upperLeftY === 0) upperLeftY = "";
if (width === 0) width = "";
if (height === 0) height = "";
}
}
// Map property keys to values
var vals = {
layerName: layer.name,
visibility: layer.visible,
type: type,
layerKind: getLayerKind(layer),
layerKindAM: getLayerKindAM(layer),
opacity: Math.round(layer.opacity),
blendMode: layer.blendMode,
hasMask: hasLayerMask(layer),
layerId: layer.id,
parent: parent,
upperLeftX: upperLeftX,
upperLeftY: upperLeftY,
width: width,
height: height
};
// Build array of only selected values
var infoArr = [];
for (var i = 0; i < columnProperties.length; i++) {
infoArr.push(vals[columnProperties[i]]);
}
return infoArr;
}
function hasLayerMask(layer) {
try {
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
var layerDesc = executeActionGet(ref);
return layerDesc.hasKey(stringIDToTypeID("userMaskEnabled")) &&
layerDesc.getBoolean(stringIDToTypeID("userMaskEnabled"));
} catch (e) {
return false;
}
}
function isAdjustmentLayer(layer) {
try {
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
var layerDesc = executeActionGet(ref);
if (layerDesc.hasKey(stringIDToTypeID("layerKind"))) {
var layerKind = layerDesc.getInteger(stringIDToTypeID("layerKind"));
return layerKind === 2;
}
return false;
} catch (e) {
return false;
}
}
function getLayerKind(layer) {
try {
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
var layerDesc = executeActionGet(ref);
if (layerDesc.hasKey(stringIDToTypeID("layerKind"))) {
var kindValue = layerDesc.getInteger(stringIDToTypeID("layerKind"));
var kindString = "";
switch (kindValue) {
case 0: kindString = "LayerKind.UNDEFINED"; break;
case 1: kindString = "LayerKind.NORMAL"; break;
case 3: kindString = "LayerKind.TEXT"; break;
case 4: kindString = "LayerKind.SHAPELAYER"; break;
case 5: kindString = "LayerKind.SMARTOBJECT"; break;
case 6: kindString = "LayerKind.VIDEO"; break;
case 7: kindString = "LayerKind.LAYERSECTION"; break;
case 8: kindString = "LayerKind.LAYER3D"; break;
case 9: kindString = "LayerKind.GRADIENTFILL"; break;
case 10: kindString = "LayerKind.PATTERNFILL"; break;
case 11: kindString = "LayerKind.SOLIDFILL"; break;
case 12: kindString = "LayerKind.BACKGROUND"; break;
case 13: kindString = "LayerKind.HIDDENSECTIONBOUNDER"; break;
case 14: kindString = "LayerKind.VECTOR"; break;
}
if (kindValue === 2) {
var adjustmentDesc = layerDesc.getList(stringIDToTypeID("adjustment"));
if (adjustmentDesc.count > 0) {
var adjustmentType = adjustmentDesc.getObjectType(0);
switch (adjustmentType) {
case stringIDToTypeID("levels"): kindString = "LayerKind.LEVELS (Adjustment Layer)"; break;
case stringIDToTypeID("curves"): kindString = "LayerKind.CURVES (Adjustment Layer)"; break;
case stringIDToTypeID("colorBalance"): kindString = "LayerKind.COLORBALANCE (Adjustment Layer)"; break;
case stringIDToTypeID("brightnessContrast"): kindString = "LayerKind.BRIGHTNESSCONTRAST (Adjustment Layer)"; break;
case stringIDToTypeID("hueSaturation"): kindString = "LayerKind.HUESATURATION (Adjustment Layer)"; break;
case stringIDToTypeID("selectiveColor"): kindString = "LayerKind.SELECTIVECOLOR (Adjustment Layer)"; break;
case stringIDToTypeID("channelMixer"): kindString = "LayerKind.CHANNELMIXER (Adjustment Layer)"; break;
case stringIDToTypeID("gradientMapClass"): kindString = "LayerKind.GRADIENTMAP (Adjustment Layer)"; break;
case stringIDToTypeID("invert"): kindString = "LayerKind.INVERSION (Adjustment Layer)"; break;
case stringIDToTypeID("posterize"): kindString = "LayerKind.POSTERIZE (Adjustment Layer)"; break;
case stringIDToTypeID("thresholdClassEvent"): kindString = "LayerKind.THRESHOLD (Adjustment Layer)"; break;
case stringIDToTypeID("blackWhite"): kindString = "LayerKind.BLACKWHITE (Adjustment Layer)"; break;
case stringIDToTypeID("vibrance"): kindString = "LayerKind.VIBRANCE (Adjustment Layer)"; break;
case stringIDToTypeID("colorLookup"): kindString = "LayerKind.COLORLOOKUP (Adjustment Layer)"; break;
case stringIDToTypeID("exposure"): kindString = "LayerKind.EXPOSURE (Adjustment Layer)"; break;
case stringIDToTypeID("photoFilter"): kindString = "LayerKind.PHOTOFILTER (Adjustment Layer)"; break;
case stringIDToTypeID("blackAndWhite"): kindString = "LayerKind.BLACKANDWHITE (Adjustment Layer)"; break;
default: kindString = "Unknown Adjustment Layer (" + typeIDToStringID(adjustmentType) + ")";
}
} else {
kindString = "Unknown Adjustment Layer";
}
}
if (layer.isBackgroundLayer) {
kindString += " isBackground";
}
return kindString;
}
return "LayerKind.UNKNOWN";
} catch (e) {
return "Error: " + e.message;
}
}
function getLayerKindAM(layer) {
try {
var s2t = stringIDToTypeID;
var r = new ActionReference();
r.putProperty(s2t('property'), s2t('layerKind'));
r.putIdentifier(s2t('layer'), layer.id);
var layerKind = executeActionGet(r).getInteger(s2t('layerKind'));
var kindStringAM = "";
if (layerKind === 0) {
kindStringAM = "kAnySheet";
} else if (layerKind === 1) {
kindStringAM = "kPixelSheet";
} else if (layerKind === 2) {
var rAdj = new ActionReference();
rAdj.putProperty(s2t('property'), s2t('adjustment'));
rAdj.putIdentifier(s2t('layer'), layer.id);
var adjustmentList = executeActionGet(rAdj).getList(s2t('adjustment'));
if (adjustmentList.count > 0) {
var adjustmentType = typeIDToStringID(adjustmentList.getObjectType(0));
kindStringAM = "kAdjustmentSheet (" + adjustmentType + ")";
} else {
kindStringAM = "kAdjustmentSheet (Unknown)";
}
} else if (layerKind === 3) {
kindStringAM = "kTextSheet";
} else if (layerKind === 4) {
kindStringAM = "kVectorSheet";
} else if (layerKind === 5) {
kindStringAM = "kSmartObjectSheet";
} else if (layerKind === 6) {
kindStringAM = "kVideoSheet";
} else if (layerKind === 7) {
kindStringAM = "kLayerGroupSheet";
} else if (layerKind === 8) {
kindStringAM = "k3DSheet";
} else if (layerKind === 9) {
kindStringAM = "kGradientSheet";
} else if (layerKind === 10) {
kindStringAM = "kPatternSheet";
} else if (layerKind === 11) {
kindStringAM = "kSolidColorSheet";
} else if (layerKind === 12) {
kindStringAM = "kBackgroundSheet";
} else if (layerKind === 13) {
kindStringAM = "kHiddenSectionBounder";
} else {
kindStringAM = "Unknown AM Kind (" + layerKind + ")";
}
if (layer.isBackgroundLayer) {
kindStringAM += " (isBackground = true)";
}
return kindStringAM;
} catch (e) {
return "Error: " + e.message;
}
}
Copy link to clipboard
Copied
Hello, the merging of the threads made it very difficult to follow.
@MXKS could you maybe post the explanation in your native language?
The way I understand, you would like to have a script that would 1) name layers from a given order 2) change the layers position from top to bottom?
Copy link to clipboard
Copied
Hello, the merging of the threads made it very difficult to follow.
@MXKS could you maybe post the explanation in your native language?
The way I understand, you would like to have a script that would 1) name layers from a given order 2) change the layers position from top to bottom?
By @PECourtejoie
Truth be told, it was a dog's breakfast before then, perhaps even from the start? This is a serial issue with almost every topic created by MXKS. For what it is worth, my vote would be to press the reset button (lock the thread and start again).
I also agree that the online translator used by the OP is not helping, posting in their native language and stating in English which language this is would help interested parties to use their own preferred translation services to read the question. That being said, translation is only part of the problem. Clear concise step by step points stating the objective and steps, with screenshots with useful annotations would surely help from the very start.
Copy link to clipboard
Copied
For Better Under I posted the image @Stephen Marsh
Step 1:- I have 4Layers Of Squre.
Step 2:- I want to Select top to bottom like second image in scripts
Here is script >..
@
Copy link to clipboard
Copied
@PECourtejoie Yes, I want top to bottom layer
Copy link to clipboard
Copied
You then need to change the sorting of the selected layers by their position over the canvas. Right now the sort is from the left to right and bottom to top. You want the sort to be from left to right and top to bottom. You need to modify script's Sort compare function to sort the array of selected layer in the order you want to rename them in.
You need to modify the scripts code in "function cmp(a, b)"
I do not know how to do that. I do not understand how javascript .sort() method works. When I change it to.
function cmp(a, b)
{
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), a);
var b1 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l1 = b1.getUnitDoubleValue(stringIDToTypeID("left"));
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("bounds"));
r.putIdentifier(stringIDToTypeID("layer"), b);
var b2 = executeActionGet(r).getObjectValue(stringIDToTypeID("bounds"));
var l2 = b2.getUnitDoubleValue(stringIDToTypeID("left"));
return l1 + l2;
}
catch (e) { throw(e); }
}
The layers were sorted into the order I populated the template which surprised me I expected the center image would be sorted to the middle of the group. I clearly do not know how sort works. My change may have just killed the sort the layer array order was not changed. Layer were renamed layer stack order as shown. I have no idea what the function should return to .sort() its time to hits the references books for me. I know it should retun an indicator yes or no to change order.
JavaScript Array sort: Sorting Array Elements
Copy link to clipboard
Copied
Yesn But I don't know how to modify the "function cmp(a, b)"
Could you mofidy the script please @JJMack
Lots of time waste for me just one thing please solve the problem
Copy link to clipboard
Copied
So now that a read a bit about sort, I see this script only sort layers on their left bounds it did not also compare the layers vertical top bounds. So the sort in this script to need to have logic add to also compare the layers vertical top so layers with the same left edge bounds will also be sort relative to their top bounds. You are the one that want this.. You should modify this script to work the ways you want it to. The problem is you feel the is a wast of your time. So do it manually. Its not something I want to do. Your wasting my time.
Copy link to clipboard
Copied
No, Eveyone are want this, I don't know how to logic in ps script
Everyone can't solve the problem for one thing(top to botton select layer)
Copy link to clipboard
Copied
You are wrong I do not want this script. Why would the Queen of England want any Photoshop script. It is not a problem I see no reasons why a script can not sort layers by location both horizontally and vertically. Many layers can have the same origin. Do you want these the have the same names or just ones that have identical bounds. You seem to be the only one that want this script. If everyone wants this script someone would have programmed it and made it available for a price or free. The thing is only targeted layers are renamed and if you run the script more then once on a document to rename a different set of layers the script will create duplicate layer names. Why do you want this script. If you do not how to use logic in Photoshop scripting you need to learn how to. You are not going to be able to create your custom scripts without using logic. You should stick to actions for automating things in Photoshop, Action can not have logic except for a conditionals steps and there is just a small set of condition that can be tested.
However, logic is required to do what you want to do.
Copy link to clipboard
Copied
hi sir im new here please help me.
i just want a photoshop script for auto fill image Sequentially in selected layers.
please help....
Copy link to clipboard
Copied
hi sir i just want a photoshop script, i want to first select all 8 layers
and then run script and thet below imagege is automatically fill all
8 layers sequence wise if is it possible then any body can help me.
Copy link to clipboard
Copied
Please post the template file or at least meaningful screenshots – so far it is not possible to see whether you set up Smart Objects or not.
Copy link to clipboard
Copied
hi sir i want image fill with smart object please help me
Find more inspiration, events, and resources on the new Adobe Community
Explore Now