Copy link to clipboard
Copied
Is it possible to create an action or script that will append the filename of the currently open PSD to a text file? Or if that's not possible, can a script copy the filename to the clipboard?
Thanks!
#target photoshop
var fname = activeDocument.name;
var a = new File("\\c\\filenames.txt");
a.open('a');
a.write(fname + "\n");
a.close();
Copy link to clipboard
Copied
Scripts can open file for write and write to them. There are many scripts that create text documents like html and xml files etc. JavaScript for sure supports your OS file systems. If the current active document has been save there is a file backing it and a script can retrieve its path and file name. Actions can not use logic or creat text files. Actions can have script steps.
Copy link to clipboard
Copied
#target photoshop
var fname = activeDocument.name;
var a = new File("\\c\\filenames.txt");
a.open('a');
a.write(fname + "\n");
a.close();
Copy link to clipboard
Copied
This is great. Just tried it, and it worked exactly as I need. Thank you so much!
FWIW, I modified the path for the file creation to work on Mac. In case it's useful to anyone else:
#target photoshop
var fname = activeDocument.name;
var a = new File("/Users/USERNAME/Documents/filenames.txt");
a.open('a');
a.write(fname + "\n");
a.close();
Copy link to clipboard
Copied
Note that code would write the document name into the filenames.txt file. It may or may not have and extension and the document may not have been saved so no file may exists and there is no path written
Copy link to clipboard
Copied
Is this javascript or something else?
Copy link to clipboard
Copied
Specifically ExtendScript.