# Saving History Log File Automatically via batchPlay Command

**URL:** <https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050>\
**Category:** UXP Plugin API\
**Tags:** javascript\
**Created:** [August 3, 2022, 4:17pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050 "2022-08-03T16:17:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 3, 2022, 4:17pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/1 "2022-08-03T16:17:27Z")

</div>

Hello,

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:

```auto

// BEFORE COMPLETING THE TASK IT IS GOING TO SAVE THE LOG
    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.

 ![Screen Shot 2022-08-03 at 19.16.59](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/25f4020ac53c6cf7e2c4740b08839732dccaee17.png)

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

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [August 3, 2022, 11:54pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/2 "2022-08-03T23:54:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 4, 2022, 9:27am UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/3 "2022-08-04T09:27:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [August 4, 2022, 9:40am UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/4 "2022-08-04T09:40:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 4, 2022, 1:27pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/5 "2022-08-04T13:27:05Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/a/a31d19bda8ef296058359562045f40a9f108bfa1.png)

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [August 4, 2022, 2:03pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/6 "2022-08-04T14:03:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 5, 2022, 12:36pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/7 "2022-08-05T12:36:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [August 5, 2022, 1:13pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/8 "2022-08-05T13:13:18Z")

</div>

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](https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createsessiontokenentry)

Someone correct me if I’m mistaken

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [August 5, 2022, 1:16pm UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/9 "2022-08-05T13:16:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 8, 2022, 7:37am UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/10 "2022-08-08T07:37:10Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![beyz](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/beyz/32/2322_2.png) [@beyz](https://forums.creativeclouddeveloper.com/u/beyz)\
**Post date:** [August 17, 2022, 6:26am UTC](https://forums.creativeclouddeveloper.com/t/saving-history-log-file-automatically-via-batchplay-command/5050/11 "2022-08-17T06:26:59Z")

</div>

> [@Jarda](#):
>
> o translate recorded action/batchPlay into hu

@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 😅 However, it would be great if you could share if these mappings already exist.  
E.g

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