Copy link to clipboard
Copied
Hello everybody,
I have a file with different layers. One of them is a text layer that displays a code for that specific illustration. I need this internal code to be the name of the .psd file too.
I've been doing it on my own, by copying the text in the layer and then pasting it when saving the file. I've heard that there's an action that can automatically do this by reading the layer's content and placing it in the save window as the filename.
Hope someone's been dealing with something like this and has an easy answer.
Thanks so much,
Enrico
You may want to ask over at
Copy link to clipboard
Copied
You may want to ask over at
Copy link to clipboard
Copied
The »correct answer«-ranking seems to be more than the post merits, but I expect that some of the regulars over on the Photoshop Scripting Forum should be able and willing to help you out.
Copy link to clipboard
Copied
Yeah, I just thought that marking it as »correct answer« would be helpful to let people know I had moved the question to the other forum.
This is the direct link to the new post: https://forums.adobe.com/thread/2468630
Copy link to clipboard
Copied
One of the most easiest script there can be wrote to achieve your goal - moderator move it please to: Photoshop Scripting
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document' ), sTT('ordinal'), sTT('targetEnum'))
l = executeActionGet(ref).getInteger(sTT('numberOfLayers')) + 1
while(--l) {
(ref = new ActionReference()).putIndex(sTT('layer'), l)
if ((dsc = executeActionGet(ref)).hasKey(sTT('textKey'))) {
(aD = activeDocument).saveAs(File(aD.path + '/' + dsc.getObjectValue
(sTT('textKey')).getString(sTT('textKey')))), aD.close(); break
}
}
Open Notepad and save it as "Text.jsx" (incl. double quotes). Copy new file to Presets/Scripts folder that is in your Ps folder. Relaunch Photoshop. Open file that the script has to be run on. Finally from File / Scripts click on script that is named: Text
You may of course bind some key to that Script to have shortcut instead of accessing it each time from menu.
Besides if you'll answer my questions I make automation process for all documents you want it was applied for.
Are these Files you want to use text content for file name in the same folder, or different ones?
Irrecpectively they are in different ones or just the same, tell me entire path to their parent folder.
Are you doing something else beside copying that text code to file name? - describe whole process.
Would you like opened file was closed after saving and then original .psd was renamed or removed?
Copy link to clipboard
Copied
Wow! Thanks a lot Kukurykus!
I've tried it and it works. But, if possible, I'd like to ask you one change: I'd prefer the script to ask the user where to save the new file. (by opening up the "save as" window already displaying the fetched name, or just asking where to save)
Then, it's ok for me to create the new .psd file and keep it open while leave the original .psd intact.
Hope you can help with this too!
Copy link to clipboard
Copied
if (documents.length) {$.level = 0; try{
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document' ), sTT('ordinal'), sTT('targetEnum'))
l = executeActionGet(ref).getInteger(sTT('numberOfLayers')) + 1
while(--l) {
(ref = new ActionReference()).putIndex(sTT('layer'), l)
if ((dsc = executeActionGet(ref)).hasKey(sTT('textKey'))) {
fld = Folder((aD = activeDocument).path).selectDlg('Folder:')
aD.saveAs(Folder(fld + '/' + dsc.getObjectValue(sTT('textKey'))
.getString(sTT('textKey')))); break
}
}
}
catch(err) {alert(err.message)}}