Copy link to clipboard
Copied
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
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();
};
Copy link to clipboard
Copied
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();
};
Copy link to clipboard
Copied
That would do it. Thanks so much. Out of curiosity, is that anywhere in Adobe docucmentation or is this pure Javascript?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It does. Thanks for the assist.
Copy link to clipboard
Copied
There is documentation .pdf called JavaScript Tools Guide, also available under Help menu
Copy link to clipboard
Copied
right now this code saves the text file to the desktop.
what if we wanted to save it to:
C:\MyFolder\MyFiles
instead?
- 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();
- };
Copy link to clipboard
Copied
If 'MyFolder' already exists, replace input of new File(), to "/c/MyFolder/ScriptLog.txt"
Copy link to clipboard
Copied
What are the params ("e", "TEXT", "????") in file.open for?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
excellent, thank you Kukurykus!!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more