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

Add additional space to string at every existing space

Explorer ,
Dec 14, 2019 Dec 14, 2019

Copy link to clipboard

Copied

Hello, I'm trying to make a script that edits a layer's text by adding another space at every instance there is already an existing space. 

"Edit spaces" to

"Edit  spaces"

Any help much appreciated. Thanks in advance!

TOPICS
Actions and scripting , Windows

Views

1.1K
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
Adobe
Community Expert ,
Dec 14, 2019 Dec 14, 2019

Copy link to clipboard

Copied

Hi it can be done with Actions you need to record it...Regards

Ali Sajjad / Graphic Design Trainer / Freelancer / Adobe Certified Professional

Votes

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 ,
Dec 14, 2019 Dec 14, 2019

Copy link to clipboard

Copied

How can it be done with an action.  Actions can not use logic to retrieve text layers and search for spaces and insert additional spaces.  And if  you double the amount of spaces how would an action known if the revised text will fit on canvas.  How would an action know how many text layer there are  or where in the layer stack text layers are.  A Photoshop script may be able to do what they want to do. It would not be easy to program such a Photoshop script. If it is not something  they would use all the time they would save time manually editing their text layers.

JJMack

Votes

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
Guide ,
Dec 16, 2019 Dec 16, 2019

Copy link to clipboard

Copied

in action it colud be done throw find&replace menu of text item

2019-12-16_12-34-15.pngexpand image

Votes

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 ,
Dec 16, 2019 Dec 16, 2019

Copy link to clipboard

Copied

Yes you can record find and replace.  How well  replacing a space with two spaces can get very messy when there are consecutive spaces in the text also expending the length of text with extra spaces can result  with text not fitting within the text area  verbiage will not be displayed in the document. IMO Find and replace should be used manually not in an action. Text can be quite complex to the deal with in automation it above my pay grade.

Capture.jpgexpand image

.

JJMack

Votes

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 ,
Dec 14, 2019 Dec 14, 2019

Copy link to clipboard

Copied

You can use Google search to search for scripts poster on this site for editing text layers.  Some have been posted. This site search is useless for searching for things like that. Use Google.

JJMack

Votes

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 ,
Dec 14, 2019 Dec 14, 2019

Copy link to clipboard

Copied

Try this:

var textI = app.activeDocument.activeLayer.textItem
textI.contents = textI.contents.replace(/ /g,"  ");

Votes

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 ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

Hmm, this is seemingly exactly what I want, however, doesn't seem to be working for me. Did this actually work for you? Something that's interesting is I copy/pasted the below code from my file, and the number of spaces between the " " pasted as only one, despite in the code having several. Curious..

 

var myText = doc.activeLayer.textItem
myText = myText.contents.replace(/ /g," ");

 

 

Votes

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 ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

You only have one space between the quotes, you need two. What you are doing is replacing a single space with another single space.

Votes

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 ,
Dec 24, 2019 Dec 24, 2019

Copy link to clipboard

Copied

Chuck, that's what I'm saying. It pasted here with only 1 space but in my actual code there are several. This is what makes me wonder if this method indeed works. Thanks 

Votes

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 ,
Dec 25, 2019 Dec 25, 2019

Copy link to clipboard

Copied

LATEST

Do you only have one space between the forward slashes - / /, and two spaces between the quotes - "  "? It's working fine for me.

double space.jpgexpand image

Votes

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 ,
Dec 15, 2019 Dec 15, 2019

Copy link to clipboard

Copied

 

"Edit spaces" to

"Edit spaces"

 

It sounds like you are trying to get more word spacing? If that's the case it would be easier to manipulate the word spacing via the Paragraph Style.

 

So the default Word Spacing is 80 |100 |133

 

 

Screen Shot 1.pngexpand image

 

You can increase the Word Spacing and keep the same Letter Spacing:

 

Screen Shot.pngexpand image

Votes

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