# Place file from a different folder (UXP script not plugin)

**URL:** <https://forums.creativeclouddeveloper.com/t/place-file-from-a-different-folder-uxp-script-not-plugin/8002>\
**Category:** Photoshop\
**Created:** [June 13, 2024, 3:40pm UTC](https://forums.creativeclouddeveloper.com/t/place-file-from-a-different-folder-uxp-script-not-plugin/8002 "2024-06-13T15:40:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://avatars.discourse-cdn.com/v4/letter/f/db5fbb/32.png) [@fred](https://forums.creativeclouddeveloper.com/u/fred)\
**Post date:** [June 13, 2024, 3:40pm UTC](https://forums.creativeclouddeveloper.com/t/place-file-from-a-different-folder-uxp-script-not-plugin/8002/1 "2024-06-13T15:40:52Z")

</div>

Hi, once the user gets a folder with the file picker, is it possible to programaticaly open other files within the same path? How do I create the createSessionToken with a relative path? For example:

user picks “parent/file/pic.jpg”  
later open programmaticaly: “parent/otherFile/otherPic.jpg”

```auto
    const myFolder = await fs.getFolder();
    const myEntry = await myFolder.getEntries();

    for (const entry of myEntry) {
        await batchPlay([{
            _obj: "placeEvent",
            linked: true,
            "target": {
                _path: await fs.createSessionToken(myEntry), 
                _kind: "local",
            },
        }
        ], {});

```

---

<div class="post-metadata">

**Author:** ![fred](https://avatars.discourse-cdn.com/v4/letter/f/db5fbb/32.png) [@fred](https://forums.creativeclouddeveloper.com/u/fred)\
**Post date:** [June 14, 2024, 3:57pm UTC](https://forums.creativeclouddeveloper.com/t/place-file-from-a-different-folder-uxp-script-not-plugin/8002/2 "2024-06-14T15:57:49Z")

</div>

Working solution with fs.getEntryWithUrl():

```auto
const photoshop = require("photoshop");
const { app, constants} = photoshop;
const { showAlert } = photoshop.core;
const {batchPlay} = require("photoshop").action;
const fs = require('uxp').storage.localFileSystem;

try {
    // create a new doc
    const doc = app.documents.add({height:960,width:540,resolution:72,name:"mainDoc"});

    // THIS WORKS BY ITSELF (WITHOUT FILE PICKER)
    // const pic = await fs.getEntryWithUrl(`/Users/user/Documents/UXP/UXP_Tutorials/BatchPlay/_img/myImage.jpg`)

    // FILE PICKER
    const myFolder = await fs.getFolder();
    await showAlert(`myFolder: ${myFolder.nativePath}`);
    const pic = await fs.getEntryWithUrl(`${myFolder.nativePath}/_img/myImage.jpg`)

    await batchPlay([{
        _obj: "placeEvent",
        linked: true,
        "target": {
            _path: await fs.createSessionToken(pic),
            _kind: "local",
        },
    }
    ], {});
} 
catch (e) {
    showAlert(e)
    debugger;
}

```
