Can UXP open a folder via JS like CEP does?

With CEP I use to open a folder previously given by user so the user can access faster his exported image with the next code:

Folder(outputFolder).execute();

The code above opens the Window or Mac explorer on the outputFolder path.

Is there a way to do it with the a session token within UXP?

This is a great UX that I want to remain in my plugin as I’m migrating it to UXP from CEP.

Thanks in advance!

I think it is supposed to be this:
https://developer.adobe.com/xd/uxp/uxp/reference-js/Modules/shell/Shell/
But I had tried it in the past and wasn’t able to get it to work and gave up.

Hello Jason, this is exactly what I needed thank you very much brother! It works perfect for me and opens the folder without a problem!

Do you want to share with me what you’ve tried so I can help you to make it work and return you the favor?

Cheers!

I don’t think I currently need that function, but if you have some working example code you could put here, that would be helpful to me or others in the future.

1 Like

I would like that! I was able to open files but never make a folder appear in finder/explorer… I just assumed it was bugged and would get fixed later.

I’m out of the studio for the weekend and I don’t have access to the updated code which worked for me but I’ll be back on Monday and then I can share with you the exact code I used! I just put a reminder on my calendar to write back here!

1 Like

I did get it working today, but thank you for checking in!

One key thing that I needed was the empty quotes “” in the “extensions” array in the manifest!
manifest.json snippet

  "requiredPermissions": {
    "localFileSystem": "fullAccess",
    "launchProcess": {
      "schemes": [
        "http",
        "https"
      ],
      "extensions": [
        ".svg",
        ".png",
        ".psb",
        ".psd",
        ".jpeg",
        ".jpg",
        ".tif",
        ".txt",
        ".json",
        ".exe",
        ""
      ]
    },

main.js

const lfs = require("uxp").storage.localFileSystem;
require("uxp").shell;

token = await lfs.getFolder();
shell.openPath(token.nativePath);
3 Likes

Intersting! I can open it without having the extensions key with all those values on it in the mafiest! I did the same as you, I already checked my code, I used the token.nativePath value in the openPath() function and worked as well.

1 Like

I should check what happens if I just remove the extensions key entirely. Maybe it is triggering a needless “whitelist” situation.

1 Like