10 Replies Latest reply on Nov 7, 2016 3:30 PM by tokuredit

    How to copy the name of the folder and paste as text in Photoshop

    tokuredit Level 1

      I have about 200 image files of various sizes separated by folders, each folder represents a different customer. I need a text layer in each image that matches the name of each folder. It would be like this:

       

      • 1 Select Folder

      • 2 Copy the folder name

      • 3 Open the image

      • 4 Paste into a text layer. "Adding text in the image"

       

      I found this script, it's almost all I need: Only a change: Change the file name to the folder name. Thank you.

       

      // add document name in text layer;

      #target photoshop

      if (app.documents.length > 0) {

      var myDocument = app.activeDocument;

      var originalUnits = app.preferences.rulerUnits;

      app.preferences.rulerUnits = Units.PIXELS;

      // getting the name;

      var docName = myDocument.name;

      //var basename = docName.match(/(.*)\.[^\.]+$/)[1];

      //getting the location;

      //var docPath = myDocument.path;

      // make the layer;

      var myLayerRef = myDocument.artLayers.add();

      myLayerRef.kind = LayerKind.TEXT;

      myLayerRef.name = "text";

      var myTextRef = myLayerRef.textItem;

      myTextRef.size = 12;

      myTextRef.font = "Arial";

      myTextRef.justification = Justification.RIGHT;

      //Set text colour in RGB values

      var newColor = new SolidColor();

      newColor.rgb.red = 192;

      newColor.rgb.green = 44;

      newColor.rgb.blue = 44;

      myTextRef.color = newColor;

      // Set the position of the text - percentages from left first, then from top.

      myTextRef.position = new Array( myDocument.width -670, myDocument.height -1640);

      myLayerRef.blendMode = BlendMode.NORMAL;

      myLayerRef.opacity = 100;

      myTextRef.contents = docName;

      app.preferences.rulerUnits = originalUnits;

      };

      //that’s it; thanks to xbytor;