How do I save a file with batchPlay to the temporary folder?

I was in the same situation as you and had to experiment around, because the documentation was not very helpful. In the end I found out that I had to create a session token. Hopefully this is useful for someone:

const tempFolder = await fs.getTemporaryFolder()
const token = fs.createSessionToken(tempFolder);

const edit = [{
  _obj: "save",
  as: {
    _obj: "JPEG",
    extendedQuality: 9,
    matteColor: {
      _enum: "matteColor",
      _value: "none"
    }
  },
  in: {
    _path: token,
    _kind: "local"
  },
  lowerCase: true,
  saveStage: {
    _enum: "saveStageType",
    _value: "saveBegin"
  },
  _isCommand: false
}]

await photoshop.action.batchPlay(edit, {
  synchronousExecution: false
})
3 Likes