Link in Zwischenablage kopieren
Kopiert
Hello
i have a psd file with about 40 artboards which are the same graphics/layers but in difrrent sizes
and i want the ability to change a pargraph across all artboards
but for some reason when even i try to paste a long paragraph into the "find and replace text" window, it wont paste it at all and leave the field empty.
i searched everywhere and didnt find that there are limitations to number of characters in this field
so what is the problem? and is there a fix?
i atached a sample psd file
and this is a demo for long text that wont paste instead of the legal text in the attached psd file:
"this is a long demo text that i cant seem to actully paste into find and replace tool in photoshop and this just ruins my intire process for building banners grid, which i have to be able to do in order to create grid for many banners who i need to produce"
thank you
lital
@Lital2252941669o3 wrote:
but i need the possibility to input a diffrent paragraph each time (i have 100 diffrent ones for 40 diffrent banner sizes)
is there a way to do this for a panel like the find and replace where i could input text?
OK, here is a new version using a single scriptUI dialog rather than two separate prompts:
/*
Unlimited Input Find & Replace.jsx
v1.0 - 17th May 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/find-and-replace-text-wont-
...
Link in Zwischenablage kopieren
Kopiert
No problem on my side. I am on Windows running 24.4.1 Photoshop. Wait someone with Mac to confirm. What is your Ps version by the way? And if you can change font to something that everyone have installed like Arial to skip trouble replacing text and missing Glyphs.
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
Does not work with less then 255 characters (including spaces I guess)?
Link in Zwischenablage kopieren
Kopiert
Yes, including spaces.
Link in Zwischenablage kopieren
Kopiert
thank you all
i wanted to ask if its possible to change it with a script and then got the answer from @Stephen Marsh
so hopefully you can help me write a script to input what ever long text needed so i could preduce the 100 difrrent banners i need
thank you all again
Link in Zwischenablage kopieren
Kopiert
As @ktaki informs us that this is a GUI limitation, we can do away with the native GUI:
Select one of the "put the legal text here" text layers, then run this script:
#target photoshop
var findText = "put the legal text here";
var replaceText = "this is a long demo text that i cant seem to actully paste into find and replace tool in photoshop and this just ruins my intire process for building banners grid, which i have to be able to do in order to create grid for many banners who i need to produce";
var idreplace = stringIDToTypeID("replace");
var desc483 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref135 = new ActionReference();
var idproperty = stringIDToTypeID( "property" );
var idreplace = stringIDToTypeID( "replace" );
ref135.putProperty( idproperty, idreplace );
var idtextLayer = stringIDToTypeID( "textLayer" );
var idordinal = stringIDToTypeID( "ordinal" );
var idallEnum = stringIDToTypeID( "allEnum" );
ref135.putEnumerated( idtextLayer, idordinal, idallEnum );
desc483.putReference( idnull, ref135 );
var idusing = stringIDToTypeID( "using" );
var desc484 = new ActionDescriptor();
var idfind = stringIDToTypeID( "find" );
desc484.putString( idfind, findText );
var idreplace = stringIDToTypeID( "replace" );
desc484.putString( idreplace, replaceText );
var idcheckAll = stringIDToTypeID( "checkAll" );
desc484.putBoolean( idcheckAll, true );
var idforward = stringIDToTypeID( "forward" );
desc484.putBoolean( idforward, true );
var idcaseSensitive = stringIDToTypeID( "caseSensitive" );
desc484.putBoolean( idcaseSensitive, false );
var idwholeWord = stringIDToTypeID( "wholeWord" );
desc484.putBoolean( idwholeWord, false );
var idignoreAccents = stringIDToTypeID( "ignoreAccents" );
desc484.putBoolean( idignoreAccents, true );
var idfindReplace = stringIDToTypeID( "findReplace" );
desc483.putObject( idusing, idfindReplace, desc484 );
executeAction( idreplace, desc483, DialogModes.NO );
app.beep();
For a very quick GUI, you could replace the first two static variable lines with prompts, such as:
var findText = prompt("Find text:", "put the legal text here");
var replaceText = prompt("Replace text:", "this is a long demo text that i cant seem to actully paste into find and replace tool in photoshop and this just ruins my intire process for building banners grid, which i have to be able to do in order to create grid for many banners who i need to produce");
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Link in Zwischenablage kopieren
Kopiert
thank you but i tried the script and got an error
Link in Zwischenablage kopieren
Kopiert
You didn't read my blogpost carefully enough, you saved the code as an RTF (rich text format) – not as a plain text format TXT file.
Mac: Apple TextEdit (ensure that the Format menu is set to Plain Text mode, not Rich Text mode)
Link in Zwischenablage kopieren
Kopiert
I'm testing on the Mac and was surprised with the results of the backdoor approach of changing DialogModes.NO to DialogModes.ALL – the text string passed from the variable to the GUI wasn't truncated at 255 characters!
Link in Zwischenablage kopieren
Kopiert
im sorry you were right, the script worked. but i need the possibility to input a diffrent paragraph each time (i have 100 diffrent ones for 40 diffrent banner sizes)
is there a way to do this for a panel like the find and replace where i could input text?
Link in Zwischenablage kopieren
Kopiert
@Lital2252941669o3 wrote:
but i need the possibility to input a diffrent paragraph each time (i have 100 diffrent ones for 40 diffrent banner sizes)
is there a way to do this for a panel like the find and replace where i could input text?
You can:
1) Simply update the static text in the script before running it.
2) Or use my second suggestion of changing the first two variables from text strings to prompts.
3) Or... Alternatively, a custom scriptUI dialog could be created, or an entire UXP plugin panel.
EDIT: I have provided a new version using scriptUI!
Link in Zwischenablage kopieren
Kopiert
@Lital2252941669o3 wrote:
but i need the possibility to input a diffrent paragraph each time (i have 100 diffrent ones for 40 diffrent banner sizes)
is there a way to do this for a panel like the find and replace where i could input text?
OK, here is a new version using a single scriptUI dialog rather than two separate prompts:
/*
Unlimited Input Find & Replace.jsx
v1.0 - 17th May 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/find-and-replace-text-wont-work-on-long-text/td-p/13793461
*/
// Configure the text parameters to pass to the main window function
// Non breaking space character \u00A0 to avoid truncation on Win OS
findReplaceDialog("Find & Replace Interface v1.0", "Find:\u00A0", "Replace (No 255 Character Limit):\u00A0");
// Main function
function findReplaceDialog(promptTitle, promptString, promptString2) {
try {
// PROMPT WINDOW
var promptWindow = new Window("dialog");
promptWindow.text = promptTitle;
/*
var gra = dialog.graphics;
//var uiBrush = gra.newBrush(gra.BrushType.SOLID_COLOR, [0.3, 0.3, 0.3, 1]);
var uiBrush = gra.newBrush(gra.BrushType.THEME_COLOR, "appDialogBackground"
gra.backgroundColor = uiBrush;
*/
promptWindow.preferredSize.width = 340;
promptWindow.preferredSize.height = 260;
promptWindow.orientation = "column";
promptWindow.alignChildren = ["left", "top"];
promptWindow.spacing = 15;
promptWindow.margins = 20;
// FIELD GROUP
var fieldGroup = promptWindow.add("group", undefined, {
name: "fieldGroup"
});
fieldGroup.orientation = "column";
fieldGroup.alignChildren = ["left", "center"];
fieldGroup.spacing = 5;
fieldGroup.margins = 0;
// FIND PROMPT FIELD LABEL
var promptLabel = fieldGroup.add("statictext", undefined, undefined, {
name: "promptLabel"
});
promptLabel.text = promptString;
promptLabel.preferredSize.height = 25;
promptLabel.preferredSize.width = 300;
// Option - swap undefined for "bold" if required
promptLabel.graphics.font = ScriptUI.newFont("dialog", undefined, 13);
/*
// TEXT COLOR
promptLabel.graphics.foregroundColor = promptLabel.graphics.newPen(promptLabel.graphics.PenType.SOLID_COLOR, [1, 1, 1], 1);
*/
// FIND PROMPT FIELD
var promptField = fieldGroup.add('edittext {properties: {name: "promptField", multiline: true, scrollable: true}}');
promptField.helpTip = "Find:";
// Default text
promptField.text = "";
//promptField.preferredSize.width = 300;
promptField.alignment = ["fill","center"];
promptField.preferredSize.height = 75;
promptField.active = true;
// REPLACE PROMPT FIELD LABEL
var promptLabel2 = fieldGroup.add("statictext", undefined, undefined, {
name: "promptLabel2"
});
promptLabel2.text = promptString2;
promptLabel2.preferredSize.height = 25;
promptLabel2.preferredSize.width = 300;
// Option - swap undefined for "bold" if required
promptLabel2.graphics.font = ScriptUI.newFont("dialog", undefined, 13);
/*
// TEXT COLOR
promptLabel.graphics.foregroundColor = promptLabel.graphics.newPen(promptLabel.graphics.PenType.SOLID_COLOR, [1, 1, 1], 1);
*/
// REPLACE PROMPT FIELD
var promptField2 = fieldGroup.add('edittext {properties: {name: "promptField2", multiline: true, scrollable: true}}');
promptField2.helpTip = "Replace:";
// Default text
promptField2.text = "";
//promptField2.preferredSize.width = 300;
promptField2.alignment = ["fill","center"];
promptField2.preferredSize.height = 75;
// BUTTON GROUP
var buttonGroup = promptWindow.add("group", undefined, {
name: "buttonGroup"
});
buttonGroup.orientation = "row";
buttonGroup.alignChildren = ["left", "top"];
buttonGroup.spacing = 0;
buttonGroup.margins = 0;
// CANCEL BUTTON
var cancelButton = buttonGroup.add("button", undefined, undefined, {
name: "cancelButton"
});
cancelButton.text = "Cancel";
cancelButton.justify = "left";
// OK BUTTON
var okButton = buttonGroup.add("button", undefined, undefined, {
name: "okButton"
});
okButton.text = "OK";
okButton.justify = "left";
// RENDER THE WINDOW & OK BUTTON ACTION
if (promptWindow.show() === 1 && (promptField.text !== "") && (promptField2.text !== "")) {
// Code to run on OK
findReplaceText();
} else {
//app.beep();
//alert("Script cancelled!");
}
// FUNCTION TO RUN WHEN THE OK BUTTON IS PRESSED
function findReplaceText() {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("property"), s2t("replace"));
reference.putEnumerated(s2t("textLayer"), s2t("ordinal"), s2t("allEnum"));
descriptor.putReference(s2t("null"), reference);
descriptor2.putString(s2t("find"), promptField.text); // Find
descriptor2.putString(s2t("replace"), promptField2.text); // Replace
descriptor2.putBoolean(s2t("checkAll"), true);
descriptor2.putBoolean(s2t("forward"), true);
descriptor2.putBoolean(s2t("caseSensitive"), false);
descriptor2.putBoolean(s2t("wholeWord"), false);
descriptor2.putBoolean(s2t("ignoreAccents"), true);
descriptor.putObject(s2t("using"), s2t("findReplace"), descriptor2);
executeAction(s2t("replace"), descriptor, DialogModes.NO);
}
} catch (err) {
alert("There was an unexpected error!" + "\r" + err + ' ' + err.line);
}
}
Link in Zwischenablage kopieren
Kopiert
wowwwwww
thats perfect
thank you very very very much
Link in Zwischenablage kopieren
Kopiert
You're welecome!
Link in Zwischenablage kopieren
Kopiert
ok so i tried this on the demo file i sent you and it worked perfect
but when i try it on the real file which has 40 artboards and the text is in hebrew
i get an error message:
do you maybe know why this is hapening?
i did this one on the same mac and same photoshop as before
Link in Zwischenablage kopieren
Kopiert
It could be related to the English vs. Hebrew text, I don't know...
You could install the ScriptingListener plug-in:
https://helpx.adobe.com/au/photoshop/kb/downloadable-plugins-and-content.html
And use that to capture the find and replace step as JavaScript code.
Then provide the code for me to update.
Link in Zwischenablage kopieren
Kopiert
ok so i tried to install the scriptlistener and it failed (it just didnt do the log file) but than i restart my mac and your script works amazingly now without changing anything
so again thank you very very much
you really helped me
Link in Zwischenablage kopieren
Kopiert
@Lital2252941669o3 – Good to know, thanks for the update. I made some minor cosmetic updates to the code, so make sure that you are using the latest version (it wasn't worth renaming as a 1.1 version). Please mark the replies that helped as a correct answer to show that this has been resolved.
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen