Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

uxp open file in photoshop mac not working

Enthusiast ,
Feb 18, 2025 Feb 18, 2025

@sttk3 

@Stephen

 

I created a button in the uxp panel that needs to open files from a folder,

to my surprise I am having a problem open file in photoshop mac does not work.

this is what came out of the action, copy javascript.

 

async function OpenFile() {
    let result;
    let psAction = require("photoshop").action;

    let command = [
        // Apri
        {"descriptor": {"_obj":"open"}, "options": {"dialogOptions": "display"}}
    ];
    result = await psAction.batchPlay(command, {});
}

async function open_file() {
    await require("photoshop").core.executeAsModal(OpenFile, {"commandName": "Action Commands"});
}

await open_file();

 

TOPICS
Actions and scripting
337
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Feb 18, 2025 Feb 18, 2025

Since open exists as a Photoshop function, you can use it directly instead of batchPlay.

 

## If you let the user specify a file to open in a dialog

No specific permissions are needed to open a file. Just pass the chosen file (Entry) to open.

 

## If you want programmatically specify a file without GUI operation by the user
Appropriate permissions are required to open the file, write `“localFileSystem”: “fullAccess”` in requiredPermissions of manifest.json.

 

Then, generate an Entry from the file path string using getEntryWithUrl and pass it to open.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 19, 2025 Feb 19, 2025

Thanks for the info The manifest is fine, I had already entered full access to the files, From what I read I can only open a file that I select, If I wanted to open 10 I have to add a few more strings.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 19, 2025 Feb 19, 2025
LATEST

I found this piece of code that does what I want,
but when I open the raw files, instead of opening them in camera raw it opens them directly in photoshop.
you can change this option.

const { app, core } = require("photoshop");
const fs = require('uxp').storage.localFileSystem;

const openFiles = async () => {
  await core.executeAsModal( async () => {
    const entry = await fs.getFolder();
    const token = await fs.createPersistentToken(entry);
    localStorage.setItem("persistentFolder", token);
    
    const thePersistentFolderToken = localStorage.getItem("persistentFolder");
    const thePersistentFolder = await fs.getEntryForPersistentToken(thePersistentFolderToken);
    // show all files
    const files = await thePersistentFolder.getEntries();
  
    for (const file of files) {
      await app.open(file)
    }    
  })
}

openFiles();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines