Session Token for Folder?

I would like to create subfolders and save images in them.
I want to avoid to have the users to constantly be confronted with a folder picker dialog like getFolder()
I have set the local file permission to “fullAccess”, like adressed here.

With the help of the Alchemist plugin, I was able to import a layer via a sessionToken:

async function importLayer(){
   const result = await batchPlay(
            _obj: "placeEvent",
            null: {
               _path: await tokenify("C:/STAPELVERARBEITUNG/Hintergrund_Artikel_Verlauf2000x2000MitteHeller.jpg"),
               _kind: "local"
            freeTransformCenterState: {
               _enum: "quadCenterState",
               _value: "QCSAverage"
            offset: {
               _obj: "offset",
               horizontal: {
                  _unit: "pixelsUnit",
                  _value: 0
               vertical: {
                  _unit: "pixelsUnit",
                  _value: 0
            _options: {
               dialogOptions: "dontDisplay"

The “tokenify” function looks like this:

async function tokenify(url){
   return fs.createSessionToken(await fs.getEntryWithUrl("file:" + url));

So naturally, I would think something like the followiing “should” work, but it doesnt, at least for me:

async function tokenifyFolder(url){
   return fs.createSessionToken(await fs.getEntryWithUrl("folder:" + url));

Am I doing something wrong? I can only find references to the “getFolder()” function to get a valid token. Thank you for your patience and help!

I have wrapped the call of the tokenifyPath function into a try catch block, this is what I got. I have a hunch that the “file:///folder:/” part is not correct:

I think regardless of whether a location is a folder or a file you should just use ‘file:’ for the URI. That said, getEntryWithUrl doesn’t actually need the ‘file:’ prefix anymore, as mentioned in this forum thread.

1 Like

Thats embarrasing… I saw that post, but didnt get its meaning at first…
Thanks for pointing me in the right direction!
There is some cross correlation, though, as this was not the only problem.
I found this thread, which lead me to believe that something is wrong with using a network drive, as a counter test revealed that getting a session token of a local folder was fine.

Basically now I am not referencing \\Server\[...], but rather beginning from the assigned network letter S:\[...].
And instead of fs.createSessionToken(await fs.getEntryWithUrl("folder:" + url)) I use fs.createSessionToken(await fs.getEntryWithUrl(url))