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

Pls help) changing text layers to one line text photoshop script

Explorer ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Hi!

I'm searching for the script that makes all text layers to one line text like below  @ @

Is it possible this function working on phoshop? 

 

br.png
TOPICS
Actions and scripting

Views

280

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Sep 25, 2024 Sep 25, 2024

Presuming that "hard" paragraph returns are used, not shift "soft" returns:

 

/*
Text Replace in All Text Layers and Groups.jsx
v1.0 - 25th July 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-adding-line-break-behind-every-comma-of-text-layer/m-p/14753971
*/

#target photoshop

if (app.documents.length > 0) {
    var doc = app.activeDocument;
    processLayersAndGroups(doc.layers);
} else {
    alert("A document must be open to run this script!");
}

fun
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Not sure what you need. Do you understand that there are two different ways of adding horizontal text in Photoshop?

Here's how:

Add point text (to add a few words like a heading or title) or paragraph text.

Point text: Click anywhere on the canvas and type the text.

Paragraph text: Drag the cursor on the canvas to create a bounding box and type your paragraph. 

Votes

Translate

Translate

Report

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
Explorer ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Hello, Derek 
Oh my english skill is not very well x)

Yep, on the point text, the text is devided because of many <br> so I need to remove the <br> and make it one sentence, but I couldn't find the script.. T T

Votes

Translate

Translate

Report

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
Explorer ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

I got help about the script code 🙂
Thank you for your reply and have a good day~!

Votes

Translate

Translate

Report

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 Expert ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Presuming that "hard" paragraph returns are used, not shift "soft" returns:

 

/*
Text Replace in All Text Layers and Groups.jsx
v1.0 - 25th July 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-adding-line-break-behind-every-comma-of-text-layer/m-p/14753971
*/

#target photoshop

if (app.documents.length > 0) {
    var doc = app.activeDocument;
    processLayersAndGroups(doc.layers);
} else {
    alert("A document must be open to run this script!");
}

function changeTextContents(layer) {
    // Check if the layer is a text layer
    if (layer.kind == LayerKind.TEXT) {
        // Regular expression to change comma+space to comma+return
        layer.textItem.contents = layer.textItem.contents.replace(/\r/g, '');
    }
}

function processLayersAndGroups(layers) {
    // Recursively process the root/top-level layers
    for (var i = 0; i < layers.length; i++) {
        var layer = layers[i];
        if (layer.typename == "ArtLayer") {
            changeTextContents(layer);
            // Recursively process the layers within all groups
        } else if (layer.typename == "LayerSet") {
            processLayersAndGroups(layer.layers);
        }
    }
}

 

Or:

 

/*
Utility PS Scripts created by David M. Converse ©2018-21

This script is a demo of replacing text

Last modified 6/2/2021

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target photoshop

layerUpdate();

function layerUpdate(){
    if(documents.length > 0){
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits;
        try{
            var docRef = activeDocument;
            preferences.rulerUnits = Units.POINTS;
            for(var i = 0; i < docRef.artLayers.length; i++){
                var LayerRef = docRef.artLayers[i];
                if(LayerRef.kind == LayerKind.TEXT){
                    var TextRef = LayerRef.textItem;
                    var layerText = TextRef.contents;
                    var newText = layerText.replace(/\r/g, '');
                    TextRef.contents= newText;
                    }
                }
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            }
        catch(e){
            }
        }
    }

 

Votes

Translate

Translate

Report

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
Explorer ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Hello, Stephen 🙂 long time no see~!
OMG you help me this time again. 
It works very well
THANK YOU SO MUCH T T!!!! nowdays I have little time so can't make the code @ @ 

Have a nice day and enjoy autumn~!

Votes

Translate

Translate

Report

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 Expert ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

LATEST
quote

Hello, Stephen 🙂 long time no see~!
OMG you help me this time again. 
It works very well
THANK YOU SO MUCH T T!!!! nowdays I have little time so can't make the code @ @ 

Have a nice day and enjoy autumn~!


By @wellearn

 

You're welcome... I'm enjoying spring though! 

Votes

Translate

Translate

Report

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