Saving History Log File Automatically via batchPlay Command


I am trying to automatically set the history log file path via a batchPlay command. However, even though I can edit the file path when I close the file Photoshop does not save the history log .txt file automatically as it does when the path was manually set. Here is my code:

    const setHistoryLogPath = async () => {

        var myFolder = await require("uxp").storage.localFileSystem.getFolder();
        let token = await require("uxp").storage.localFileSystem.createPersistentToken(myFolder);
        localStorage.setItem("persistent-token", token);
        const entry = await require("uxp").storage.localFileSystem.getEntryForPersistentToken(localStorage.getItem("persistent-token"));
        const newFile = await entry.createFile("\testing.txt", { overwrite: true });
        const saveFile = await require("uxp").storage.localFileSystem.createSessionToken(newFile);
        const result = await batchPlay(
                _obj: "set" //'save',
                _target: [
                        _ref: "property",
                        _property: "historyLogPreferences"
                        _ref: "application",
                        _enum: "ordinal",
                        _value: "targetEnum"
                to: {
                    _obj: "historyLogPreferences",
                    historyLog: true,
                    saveHistoryTo: {
                        _enum: "saveHistoryToType",
                        _value: "saveFile"
                    log: true,
                    file: {
                        _path: saveFile ,
                        _kind: "local"
                _options: {
                    dialogOptions: "display"
            synchronousExecution: false,
    require('photoshop').core.executeAsModal(setHistoryLogPath,{"commandName": "My Set Log File Command"} )


I extracted the batchPlay commands using alchemist as follows.

Can’t the history log be saved automatically? Any help would be great. Many thanks!

The event name has to be set instead of save in _obj

Otherwise, it should look very much like your code. I am currently working with same settings. The intention is to have this in DOM so I should be able to help if that would not fix the problem.

Yes. Actually, I used it in the set mode and it did not work. I was just trying to see what changes with save. Can you give me an idea of how to save each editing done using the camera raw filter just like the history log has each action with component values?

As far as I know Camera Raw will always give you one final step. Not several intermediate steps.

I see. What I wonder is how could photoshop achieve to log these steps to the history file. Can I generate this automatically somehow?
Screen Shot 2022-08-04 at 16.26.30

It does use some built-in dictionary to translate recorded action/batchPlay into human language. There are no individual steps but rather differential states before/after.

Thank you so much @Jarda I saw the non-human readable form when I was working with Alchemist.

Sorry, If I am not very clear with the questions since I am a total beginner with both Adobe Photoshop and JS/UXP/react development. Your tools are amazing and make things much simpler. Thank you for your great contribution!

I have one more question related to this. (sorry it might sound like a repetetion)

I am trying to activate the history log saving and rename the history log file.
I do this manually and it works but when I set the name (I can see that it changed) via a batchPlay command the files can not be created and thus it does not save the logs.

Alchemist inspector matches the application content as the same when history log activation is done either manually/automatically. However, the second version does not save the logs. What might be the possible reason for this?

I am not really sure where to look at it. Is there a background command that the listener or inspector cannot catch? What am I missing here?

How do you set the name via BP? Even if Alchemist shows a path, I believe you have to provide a token there. You can check some examples here

Someone correct me if I’m mistaken

Maybe you should check whether you can read and write that file before using it in batchPlay. So you would be sure to have valid instance of file and hopefully a valid token.

1 Like

@Karmalakas Thank you. You are right, we should provide a SessionToken instead of the path. I used token as you can see from the above code piece. I tried the code you provided and it did not change the result.

@Jarda I developed a solution that listens to Adobe Camera Raw Filter events and I extract the values from the descriptor. Where can I find the human-readable mappings to built-in dictionary items? I will try to map them manually since there are ways to decode them :sweat_smile: However, it would be great if you could share if these mappings already exist.

  • $CrVe: “14.4” (camera raw filter version)
  • $PrVN: 5 (process version)
  • $Temp: 1 (temperature)