What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

The find/replace feature


Rumf

Member
Messages
9
Likes
0
Hello,

Using Photoshop's find/replace tool I am trying to do this:

1. Find the word "Moon".

2. Replace it with:

"The Moon is full tonight.

How beautiful!"

The find/replace tool only replaces with the first line, "The Moon is full tonight."

It compleatly ignores what is after the paragraph break. And I need the paragraph break! I even tried to resolve this with PS scripting, I can get the whole text, but no paragraph break... And it is driving me crazy :banghead:

Any ideeas, please?!
 
I need to batch this for hundreds of files... A great someone helped with the solution today, I am attachimg a PS script just In case some needs this in the future. It replaces the word "Hello" with the contens of an external file. For paragraph breaks use \n\n

var file = new File ( "C:\\the-text-file.txt" );
file.open("r");
var open_the_file = file.read();

var str = String(open_the_file).split("\\n").join("\r");

var id3 = stringIDToTypeID( "replace" );
var desc2 = new ActionDescriptor();
var id4 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id5 = charIDToTypeID( "Prpr" );
var id6 = stringIDToTypeID( "replace" );
ref1.putProperty( id5, id6 );
var id7 = charIDToTypeID( "TxLr" );
var id8 = charIDToTypeID( "Ordn" );
var id9 = charIDToTypeID( "Al " );
ref1.putEnumerated( id7, id8, id9 );
desc2.putReference( id4, ref1 );
var id10 = charIDToTypeID( "Usng" );
var desc3 = new ActionDescriptor();
var id11 = stringIDToTypeID( "find" );
desc3.putString( id11, "Hello" );
var id12 = stringIDToTypeID( "replace" );
desc3.putString( id12, str );
var id13 = stringIDToTypeID( "checkAll" );
desc3.putBoolean( id13, true );
var id14 = charIDToTypeID( "Fwd " );
desc3.putBoolean( id14, false );
var id15 = stringIDToTypeID( "caseSensitive" );
desc3.putBoolean( id15, true );
var id16 = stringIDToTypeID( "wholeWord" );
desc3.putBoolean( id16, false );
var id17 = stringIDToTypeID( "findReplace" );
desc2.putObject( id10, id17, desc3 );
executeAction( id3, desc2, DialogModes.NO );
 
Hi Rumf, I think you have inadvertently discovered that the Find and Replace feature was not designed to incorporate paragraph breaks.

Seems you have found your solution.

Take care.
 
Last edited:

Back
Top