Confusion over automatically importing a file/multiple files

Hi Everyone,

I’ve been looking into how to properly import files as layers to be edited. I can record what’s going on via the batchplay method, but I am having trouble understanding how tokens are passed, and how the open file dialogue works, so that this can be automatically performed.

I’ve seen a thread with similar wishes here: How do you place an image from the local file system using BatchPlay?, but I was having trouble parsing what was done.

let entry = await fs.getFileForOpening();
let token = fs.createSessionToken(entry);
localStorage.setItem("this/is/the/file/path", token);

const batchCommands = [
...
{
        "_obj": "placeEvent",
        "ID": 482,
        "null": {
            "_path": token,
            "_kind": "local"
        },
...
}
...

The promise returned from this batchplay was fulfilled, but PS remained stuck in the “file open” dialogue. Is there any way to automatically get the file imported as a layer? I’m wishing to process hundreds of images.