Colleague Johan asked whether someone could knock up a script which exports all text layers from a Photoshop document to a text file. Since I’ve scripted Photoshop before (heck, I even steered Photoshop from within C#) it was no biggie for me to knock up a simple script, which I dubbed TextExport
After Johan placed his request, I quickly knocked up a script which loops all layers (1.0), then (pretty important) expanded it to loop groups of layers too (1.1) and finally added some user friendly stuff like giving one the option to choose where to save the file holding all text elements (1.2).
Download
Update November 2008:PS_BRAMUS.TextExport
is outdated and has been replaced with PS_BRAMUS.TextConvert
which does both import and export!
▼ Download PS_BRAMUS.TextExport 1.2
Installation / How to use
- Download
PS_BRAMUS.TextExport
from the link above - Extract it to Presets/Scripts folder of your Photoshop installation folder (defaults to C:\Program Files\Adobe\Adobe Photoshop CS3\Presets\Scripts on Windows)
- Restart Photoshop if it was already running
- Open the PSD you wish to export text from
- Now, when having a file opened, go to File > Scripts and select PS_BRAMUS.TextExport.1.2 from the list.
- Wait until the output file appears 🙂
Configuration
Three settings in PS_BRAMUS.TextExport
can be configured, all to be found in the .jsx
file itself.
- Open up
PS_Bramus.TextExport-1.2.jsx
with your favorite texteditor - If you want to choose where to save the file to, set
useDialog
totrue
. If set tofalse
(default), the output file will be saved into your documents folder - If you don’t want the exported file to be openend after the export has run, set
openFile
tofalse
. If set totrue
(default), the output file will automatically be opened by your default text editor. - In the export file, each line is separated by a
separator
string. Change this one to use one you like (defaults to*************************************
).
Example
I’ve tested PS_BRAMUS.TextExport
with a pretty complex PSD, which holds the design of 3RDS. Here are the results:
Input PSD
Output TXT
Make a donation
It certainly is no obligation but it would most certainly put a smile on my face 😉
Very interesting!
It would also be great to add the layer names in the textfile, no?
Text Layers by default have the same name as the text it holds; What would be neat is to add the structure in order to see what group the layer is in. Will bump a 1.3 sometime soon 😉
Hey,
This is great! I needed to get the text from 20 PSDs and wasn’t sure how to do it, I had even considered typing up the copy all over again. But this script worked really great.
I updated the script code to kill the alert prompt that the script generates to notify the user that the text export has been completed and set up a batch so now I can extract the text from a whole folder of PSDs and get the machine to do all the work.
Thanks a lot :0)
Oh, and I think you should call it “Textport” instead of Textexport 😉
Tested, verified as very useful.
Ninja-fast-slicing =)
@Wolf: still need to fix the upcoming 1.3 to work with multiple documents 😉
Ha, fixed already (little trick with the activeDocument property) … me.blogging 🙂
Thanks for sharing, lovely thingy.
Just pitty it’s kinda slow on huge PSD files with many layers..
Still thanks a lot for sharing.