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