Copy link to clipboard
Copied
I was advised to post my issue from the Photoshop section to this section. (*Note: I only have Photoshop, so saying "Use this other Adobe product" isn't a real answer for me.)
C/P from other post here: Is there a way to quickly break a single text box into multiple text boxes?
I have wished for this feature for many years, and I want to know if maybe there is a script that can do this
The scenario:
I have one text box, containing 20 names. I want 20 text boxes, each containing 1 name.
I know how to manually do it, but I want to be able to do this super fast, ie. make the machine do it for me.
Thanks!
I don’t think what you want is convenient to achieve in various possible situations.
Hndling different fonts, sizes and other settings would be highly cumbersome.
If all the text has the same type parameters you can give this a try.
...
// split lines from active typelayer;
// makes sense if the type properties are uniform;
// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = myDocument.activeLayer;
if (theLayer.kind =
Copy link to clipboard
Copied
I don’t think what you want is convenient to achieve in various possible situations.
Hndling different fonts, sizes and other settings would be highly cumbersome.
If all the text has the same type parameters you can give this a try.
// split lines from active typelayer;
// makes sense if the type properties are uniform;
// 2014, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = myDocument.activeLayer;
if (theLayer.kind == LayerKind.TEXT) {
// get text an dleading;
var theText = theLayer.textItem.contents.split("\r");
try {
var theLeading = theLayer.textItem.leading;
}
catch (e) {
var theLeading = theLayer.textItem.size * 1.2;
};
var theOffset = 0;
// work off the array;
for (var m = 0; m < theText.length; m++) {
// duplicate layer, change its contents and move it;
var theNewText = theLayer.duplicate(theLayer, ElementPlacement.PLACEBEFORE);
theNewText.textItem.contents = theText
; theNewText.translate(0, theOffset);
// amend offset;
theOffset = theOffset+theLeading
}
}
};
Copy link to clipboard
Copied
I tryed the code running Photoshop 2024 and just return 'Array', so I fixed it.
Here is the new version guys. Enjoy:
// split lines from active typelayer;
// makes sense if the type properties are uniform;
// 2014, use it at your own risk;
// 2024, update code to new photoshop versions and add 'How to Use' Comments;
/* How to use:
- Create a Text Layer with all the text with break lines
- Select the layer
- Go to File > Scripts > Split Text Lines
- Enjoy!
*/
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = myDocument.activeLayer;
if (theLayer.kind == LayerKind.TEXT) {
// get text an dleading;
var theText = theLayer.textItem.contents.split("\r");
try {
var theLeading = theLayer.textItem.leading;
}
catch (e) {
var theLeading = theLayer.textItem.size * 1.2;
};
var theOffset = 0;
// work off the array;
for (var m = 0; m < theText.length; m++) {
// duplicate layer, change its contents and move it;
var theNewText = theLayer.duplicate(theLayer, ElementPlacement.PLACEBEFORE);
theNewText.textItem.contents = theText[m];
theNewText.translate(0, theOffset);
// amend offset;
theOffset = theOffset + theLeading
}
}
};
Copy link to clipboard
Copied
How to to split numbers, alphabets into saperate layers?
I have this in single layer: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,;:?!-_~#"'&()[]|`\/@°+=*$£€<>%
I want result like this:
A
B
C
D... and so on
All numbers and albhabets in separate layers.
Copy link to clipboard
Copied
Why?
Does it have to be Type Layers or would Shape Layers work?
Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible?
Copy link to clipboard
Copied
Try this, it should work.
// Split Text Lines by Char
/* How to use:
- Save this code as "Split Text Line by Char.jsx" inside the Photoshop Folder > Presets> Scripts
- Create a Text Layer with all the text with break lines
- Select the layer
- Go to File > Scripts > Split Text Lines by Char
- Enjoy!
*/
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = myDocument.activeLayer;
if (theLayer.kind == LayerKind.TEXT) {
// get text an dleading;
var theText = theLayer.textItem.contents.split("");
try {
var theLeading = theLayer.textItem.leading;
}
catch (e) {
var theLeading = theLayer.textItem.size * 1.2;
};
var theOffset = 0;
// work off the array;
theText.pop();
for (var m = 0; m < theText.length; m++) {
// duplicate layer, change its contents and move it;
var theNewText = theLayer.duplicate(theLayer, ElementPlacement.PLACEBEFORE);
theNewText.textItem.contents = theText[m];
theNewText.translate(0, theOffset);
// amend offset;
theOffset = theOffset + theLeading
}
theLayer.remove();
}
};
Copy link to clipboard
Copied
Does one of the posted scripts work?
Copy link to clipboard
Copied
Yes, all scripts I posted works.
Copy link to clipboard
Copied
Paste the code from the previous post into a new file in ExtendScript Toolkit or a text editor and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.
After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action, be used in a Configurator-Panel or started from ExtendScript Toolkit directly.
Copy link to clipboard
Copied
So did the Script work as expected for you?
Copy link to clipboard
Copied
Perfect!
As a note to new users, in addition to breaking up the entires, the script seems to generate 2 empty layers (just delete them) and keeps the original (which is useful).
Thanks, c.pfaffenbichler !
Copy link to clipboard
Copied
Does your type layer contain blank paragraphs?
Anyways, keep in mind that the resulting type layers will have identical type properties and disregard variance.
So if you had one line in a different font that would be ignored (the font, not the line).
Copy link to clipboard
Copied
Hi there c.pfaffenbichler
I know you wrote the above answer numerous years ago, but I was wondering if it was possible to do the same script for Illustrator? I have a text box containing many lines of text and I'd love each line as individual points of text (but not individual layers). Is this even possible?
Thanks in advance for your advice and help.
Mjc
Copy link to clipboard
Copied
I assume it might be possible but I have very little familiarity with Illustrator’s DOM, so you may want to ask over at
Copy link to clipboard
Copied
I did try your script, but it didn't recognise the layers. Thanks so somuch
Copy link to clipboard
Copied
Illustrator and Photoshop have different DOMs so Scripts that go beyond fairly simple features (like opening files) are unlikely to work in both.
Copy link to clipboard
Copied
Tried your script on Adobe 2022 but unfortunately it only pastes "Array" instead of the actual text, I wonder if I'm doing something wrong. And yes, I know this was made TEN years ago but man would this be time saving.
Copy link to clipboard
Copied