Question

My goal is to create 101 separate text layers containing 0-100 (i.e. 1, 2, 3...100) I know I can mass change the attributes but cant write or alter the containing text.

Was it helpful?

Solution

What you want can easily be done with a script (easier than renaming 100 layers in all the right order and record an action for it) This script will create 100 layers of text, each layer will be named 1,2,3..etc and the text will be the same. I think that's waht you are after, your description was rather short.

// call the source document
var srcDoc = app.activeDocument;
var numOfLayers = 100;
//var numOfLayers = srcDoc.layers.length; 
var numPadding = "0";
var layerNum = 1; // change this to 0 to start layers at 0
var w = Math.floor(srcDoc.width.value/2);
var h = Math.floor(srcDoc.height.value/2);


// main loop starts here
for (var i = numOfLayers -1; i >= 0  ; i--)
{

    if (layerNum < 10) numPadding = "0";
    else numPadding ="";
    createText("Arial-BoldMT", 20.0, 0,0,0, layerNum, w, h);
    var currentLayer = srcDoc.activeLayer;
    currentLayer.name = numPadding + layerNum;
    layerNum +=1;
}

// function CREATE TEXT(typeface, size, R, G, B, content, Xpos, Ypos)
// --------------------------------------------------------
function createText(fface, size, colR, colG, colB, content, tX, tY)
{

  var artLayerRef = srcDoc.artLayers.add()
  artLayerRef.kind = LayerKind.TEXT
  textColor = new SolidColor();
  textColor.rgb.red = colR;
  textColor.rgb.green = colG;
  textColor.rgb.blue = colB;
  textItemRef = artLayerRef.textItem
  textItemRef.font = fface;
  textItemRef.contents = content;
  textItemRef.color = textColor;
  textItemRef.size = size
  textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top

  activeDocument.activeLayer.textItem.justification.CENTER
}

Save this out as numberLayers1-100.jsx and then reun it from Photoshop via the Files -> Scripts menu.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top