Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

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

Code

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.

Code

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.