ps- js- Basic write to file.txt
NOTE: These don't seem to not be working consistently in photoshop cc 2022. Need to investigate more, but don't count on it at this poing
const logFile = new File('~/Desktop/adobe-script-file.txt')
function log(msg) {
// TODO: Move this into a try catch
if (logFile.open('a', 'TEXT', '????')) {
logFile.writeln(msg)
logFile.close()
}
}
log('Hello, world')
#+OLDNOTES:
Make sure to set the lineFeed
property.
var tFile = new File('~/Desktop/missing-dir/ExtendScript-test.txt');
if (tFile.lineFeed === 'macintosh') {
tFile.lineFeed = "unix";
}
if(tFile.open('a', 'TEXT', '????')) {
tFile.writeln("asdf");
tFile.close();
}
else {
$.writeln("Could not open file: " + tFile.absoluteURI);
}
This $.writeln()
stuff used to go to ExtendScript toolkit, but that's been dead for a while now.
-- end of line --