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

script/action to append filename to text document

New Here ,
Sep 15, 2017 Sep 15, 2017

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!

TOPICS
Actions and scripting

Views

3.4K

Translate

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

correct answers 1 Correct answer

Advocate , Sep 16, 2017 Sep 16, 2017

#target photoshop

var fname = activeDocument.name;

var a = new File("\\c\\filenames.txt");

a.open('a');
a.write(fname + "\n");
a.close();

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 15, 2017 Sep 15, 2017

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.

JJMack

Votes

Translate

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
Advocate ,
Sep 16, 2017 Sep 16, 2017

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();

Votes

Translate

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
New Here ,
Sep 16, 2017 Sep 16, 2017

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(); 

Votes

Translate

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 ,
Sep 16, 2017 Sep 16, 2017

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

JJMack

Votes

Translate

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
New Here ,
Mar 05, 2020 Mar 05, 2020

Copy link to clipboard

Copied

Is this javascript or something else?

Votes

Translate

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
LEGEND ,
Mar 06, 2020 Mar 06, 2020

Copy link to clipboard

Copied

LATEST

Specifically ExtendScript.

Votes

Translate

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