Javascript find and replace text in photoshop
Hi there,
I have been trying to write a script that finds and replaces certain text files in photoshop.
For example: There was a large man called (Name) with a big burly beard.
I have created an action using find and replace text to achieve this, but in the process of trying to automate this process by converting it to javascript using Xtools it no longer works.
Any help pointing me in the right direction would be super useful.
Cheers,
Marty
#target photoshop
//
// Action1.jsx
//
//
// Generated Fri Jan 10 2020 12:56:37 GMT+1100
//
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== Action 1 ==============
//
function Action1() {
// Replace All
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), sTID("replace"));
ref1.putEnumerated(cTID('TxLr'), cTID('Ordn'), cTID('Al '));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putString(cTID('find'), "(Name)");
desc2.putString(sTID("replace"), "John");
desc2.putBoolean(sTID("checkAll"), true);
desc2.putBoolean(cTID('Fwd '), true);
desc2.putBoolean(sTID("caseSensitive"), false);
desc2.putBoolean(sTID("wholeWord"), false);
desc2.putBoolean(sTID("ignoreAccents"), true);
desc1.putObject(cTID('Usng'), sTID("findReplace"), desc2);
executeAction(sTID('replace'), desc1, dialogMode);
};
step1(); // Replace All
};
//=========================================
// Action1.main
//=========================================
//
Action1.main = function () {
Action1();
};
Action1.main();
// EOF
"Action1.jsx"
// EOF
