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

Find & replace

Community Beginner ,
May 06, 2011 May 06, 2011

I am having difficultiy finding a way to change specific text lines within a document in a batch situation. Typically if I do with an action the font size changes or there is a number of situations.  I am hoping someone might be able to point me in the right direction.

TOPICS
Actions and scripting
943
Translate
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 ,
May 07, 2011 May 07, 2011

The textItem’s contents might be what you are after.

But why not elaborate a bit, maybe with a few screenshots, so we can help you?

Translate
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
Engaged ,
May 09, 2011 May 09, 2011

You could try my seek and destroy script. Don't wory about the name, it doesn't actually destroy anything and was originally called Search and Replace but so far to my knowledge that's not a Metallica song.

Anyhoo copy the script save it out as a .jsx file

It'll prompt you for the text to seach for and the text to replace it with then it'll go through all the layers and change them accordingly. It should do what you want.

So far it works ok but has a problem with with Layer groups - but I'm just working on that.

// ******************************************************
//
// Seek and Destroy
// written by GhoulFool
// Date: 4th April 2011
// version .5
// Description:
// searches for text in layer names and replaces it
// ******************************************************

var srcDoc = app.activeDocument;
fileName = app.activeDocument.name;
var search = new Object();
var replace = new Object();
search.pattern = prompt('Enter the search pattern to look for for all layers.\n', 'Search');
replace.pattern = prompt('Enter the word to REPLACE ' + search.pattern + '.\n', 'Replace');
alert("Replacing  '"+ search.pattern + "' to be replaced with '" + replace.pattern + "'.")
var mySearch = search.pattern;
var myReplace = replace.pattern;
var numLayers = srcDoc.layers.length;
var layers = srcDoc.layers;     
processLayers (srcDoc)
function processLayers (srcDoc)
{
   for (var i = 0; i < numLayers; i++)
      {
         var layer = layers;
         if (layer.typename == 'LayerSet')
         {
            alert("This is a group")
         }
       
      else
    
         {
      var thisLayer = srcDoc.artLayers.name.toLowerCase();

            tempName = app.activeDocument.artLayers[0].name.toLowerCase();

         if (thisLayer.search(mySearch) != -1)
          
            {
            tempName = app.activeDocument.artLayers.name.toLowerCase();
            app.activeDocument.artLayers.name = tempName.replace(mySearch,myReplace)
            }
         }
      }

} // function close

Translate
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
Guide ,
May 09, 2011 May 09, 2011

Ghoulfool, your script is for the names of the layers… BTW I made one that works thru all sub layers with a couple of options only yesterday its at home thou. I think the OP wants to actually deal with the content of text layers… I'll post my script later when I get home if you want it…? I only need to add a little UI to it.

Translate
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
Engaged ,
May 09, 2011 May 09, 2011

Remember kids: Drink coffee first THEN reply to posts. Never the other way around it can lead to confusion.

Translate
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 ,
Dec 07, 2011 Dec 07, 2011
LATEST

Thanks to everyone that assisted, I eventually worked it out. I actually forgot about this post but didn't want to leave yall hanging. Muppet Mark, you were right. Thanks again

Translate
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