Skip to main content
March 8, 2013
해결됨

Is there a way with JSX to save text to a file?

  • March 8, 2013
  • 2 답변들
  • 6210 조회

I'm looking for a way to save JSX script-generated log entries to a text file, not just from Photoshop but also from InDesign and Illustrator as well. There are discussions elsewhere about using the DataObject class, but those discussions are from a few years ago, there is nothing about them (that I could find) in the CS6 documentation, and nothing comes up in EST's auto-complete. Any ideas? Thanks

이 주제는 답변이 닫혔습니다.
최고의 답변: Paul Riggott

Something like this?

logInfo((new Date).toString());
logInfo("This is the first message");

logInfo("This is the second message");

function logInfo(Txt){
var file = new File(Folder.desktop + "/ScriptLog.txt");
file.open("e", "TEXT", "????");
file.seek(0,2);
$.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh';
file.writeln(Txt);
file.close();
};

2 답변

Inspiring
January 22, 2019

excellent, thank you Kukurykus!!

Paul Riggott
Inspiring
March 8, 2013

Something like this?

logInfo((new Date).toString());
logInfo("This is the first message");

logInfo("This is the second message");

function logInfo(Txt){
var file = new File(Folder.desktop + "/ScriptLog.txt");
file.open("e", "TEXT", "????");
file.seek(0,2);
$.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh';
file.writeln(Txt);
file.close();
};

March 8, 2013

That would do it. Thanks so much. Out of curiosity, is that anywhere in Adobe docucmentation or is this pure Javascript?

Paul Riggott
Inspiring
March 8, 2013

You can find this information in the Object Model Viewer under Help in ExtendScript Toolkit

Look at Core JavaScript Classes and select File

Hope it helps.