# Open psd. file programatically

**URL:** <https://forums.creativeclouddeveloper.com/t/open-psd-file-programatically/9160>\
**Category:** UXP Plugin API\
**Created:** [February 1, 2025, 3:51am UTC](https://forums.creativeclouddeveloper.com/t/open-psd-file-programatically/9160 "2025-02-01T03:51:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![donniev](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/donniev/32/4288_2.png) [@donniev](https://forums.creativeclouddeveloper.com/u/donniev)\
**Post date:** [February 1, 2025, 3:51am UTC](https://forums.creativeclouddeveloper.com/t/open-psd-file-programatically/9160/1 "2025-02-01T03:51:46Z")

</div>

I have the requestPermsissions set to fullAccess and I can successfully read a file from the user’s file system. My use case is that I read a csv file and that file contains a list of images (psd). I want to programatically operate on those images.In particular I want to make each image and active document and then run a batchPlay on it.  
I cannot figure out how to open the file as a photoshop document.

---

<div class="post-metadata">

**Author:** ![donniev](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/donniev/32/4288_2.png) [@donniev](https://forums.creativeclouddeveloper.com/u/donniev)\
**Post date:** [February 1, 2025, 5:32am UTC](https://forums.creativeclouddeveloper.com/t/open-psd-file-programatically/9160/2 "2025-02-01T05:32:37Z")

</div>

I found the solution.

```auto
    const app = require('photoshop').app;
    const core = require('photoshop').core;
     const fs = require('fs');
    const fs2 = require("uxp").storage.localFileSystem;
    // Function to open a PSD file programmatically
    async function openDocument(filePath) {
        try {
            core.executeAsModal(async () => {
                const entryPath = await fs2.getEntryWithUrl(filePath);
                const openedDocument = await app.open(entryPath);
                console.log(openedDocument);
                // Make it the active document
                app.activeDocument = openedDocument;
                console.log(`Opened and set active: ${openedDocument.title}`);
            }, {});
        } catch (error) {
            console.error("Error opening document:", error);
        }
    }

```
