# getEntryWithUrl

**URL:** <https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453>\
**Category:** UXP Plugin API\
**Tags:** uxp\
**Created:** [June 30, 2023, 1:05am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453 "2023-06-30T01:05:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 1:05am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/1 "2023-06-30T01:05:46Z")

</div>

I’m finding that `getEntryWithUrl` isn’t working as it used to.  
This code used to work and now it’s returning the following error.

```auto
const lfs = require("uxp").storage.localFileSystem;
const doc = app.activeDocument;
const path = doc.path.slice(0, doc.path.lastIndexOf("\\"));
const entry = await lfs.getEntryWithUrl(`file:/${path}`);

```

![Screenshot 2023-06-30 015030](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/d/d482a6dedbed139991ac8ac8053c5fda6634f8c6.png)

I’ve got `"fullAccess"` set in my manifest and I’m running PS 24.6.0/UXP 7.1.0 and using the vanilla UDT starter plugin with no other code.  
Obviously the folder exists being that `path` is pulled directly from the active doc. That triple slash in the error looks weird to me, so I tried it `getEntryWithUrl` with both

```auto
(`file:${path}`)

```

and

```auto
(`${path}`)

```

but the error is the same regardless.

Is this just me having a senior moment and missing something dumb or has something changed?

@sttk3 - I know you’ve cracked this in the past, any ideas?

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [June 30, 2023, 3:30am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/2 "2023-06-30T03:30:12Z")

</div>

Now I will point out a few things I noticed.

* * *

Treating paths as just strings is a bad practice because it depends on the specific environment; use Path module. Path modules are defined as ‘path’ in UXP and should not be overwritten with a variable of the same name.

```auto
const path = doc.path.slice(0, doc.path.lastIndexOf("\\"));

```

* * *

getEntryWithUrl no longer needs a prefix ‘file:’.

```auto
const entry = await lfs.getEntryWithUrl(`file:/${path}`);

```

* * *

Here is the fixed code.

```auto
const lfs = require('uxp').storage.localFileSystem ;
const { app } = require('photoshop') ;

const main = async () => {
  const doc = app.activeDocument ;
  const folderPath = path.dirname(doc.path) ;
  const entry = await lfs.getEntryWithUrl(folderPath) ;
  console.log(entry) ;
  // --> n {Symbol(_name): "files", Symbol(_provider): {…}, Symbol(_id): {…}}
} ;

```

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 8:33am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/3 "2023-06-30T08:33:09Z")

</div>

@sttk3 nice one mate! I’d missed the introduction of the path module.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 9:17am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/4 "2023-06-30T09:17:19Z")

</div>

@sttk3 actually, that still returns the same error. I’ve tried different files in various locations on the filesystem and always the same ☹  
Is there something else I’ve missed?

```auto
const lfs = require("uxp").storage.localFileSystem;
const doc = app.activeDocument;
const folderPath = path.dirname(doc.path);

console.log("raw path", doc.path);
console.log("path", folderPath);

const entry = await lfs.getEntryWithUrl(folderPath);

console.log(entry);

```

 ![Screenshot 2023-06-30 100551](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/5/51bc842fa53e057cdfb68eb05d6bb30b0a4a6836.png)

My manifest:

```auto
{
  ...,
  "requiredPermissions": {
    "localFileSystem": "fullAccess"
  }
}

```

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [June 30, 2023, 9:28am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/5 "2023-06-30T09:28:44Z")

</div>

@Timothy_Bennett It should work, but I notice my environment is still Photoshop 24.5.0. I will update it and try it.

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [June 30, 2023, 10:27am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/6 "2023-06-30T10:27:08Z")

</div>

@Timothy_Bennett It worked in my environment. Does it not work because you are on Windows? It would be helpful to have another person’s verification.

- macOS 11.7.6 (Apple Silicon)
- Photoshop 2023 (24.6.0)

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [June 30, 2023, 10:47am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/7 "2023-06-30T10:47:12Z")

</div>

Is it possible that it should be `file://` instead of `file:///` ? I don’t understand why I see it in the screenshot of the error in console.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 10:51am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/8 "2023-06-30T10:51:24Z")

</div>

That looked odd to me too - that’s nothing to do with me, it feels like `getEntryWithUrl` is adding an extra /.  
I’ve tried it with:

```auto
getEntryWithUrl(folderPath)
getEntryWithUrl(`file:${folderPath}`)
getEntryWithUrl(`file:/${folderPath}`)

```

and they all return the same error/url.

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [June 30, 2023, 10:55am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/9 "2023-06-30T10:55:08Z")

</div>

What do you pass in? Backslash or forwardslash? In `folderPath`

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 10:59am UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/10 "2023-06-30T10:59:27Z")

</div>

> [@Timothy\_Bennett](#):
>
> ```auto
> const doc = app.activeDocument;
> const folderPath = path.dirname(doc.path);
> 
> ```

You can see in my screenshot above that `folderPath` returns backslashes.

---

<div class="post-metadata">

**Author:** ![shuji](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/shuji/32/4905_2.png) [@shuji](https://forums.creativeclouddeveloper.com/u/shuji)\
**Post date:** [June 30, 2023, 12:06pm UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/11 "2023-06-30T12:06:23Z")

</div>

I tried the code below on Windows10 and it completely works.

but after I deleted requiredPermissions on manifest.json I found same error.  
I think you could have problem on manifest.json.  
could you update full of manifest code?

 ![carbon(21)](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/6/65185c81071f5043acd10e4f707cdb0674d8de9c.png)

 ![error](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/0/049d20bfb3fcdfc91f7c9910467ad649606db46d.png)

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [June 30, 2023, 12:12pm UTC](https://forums.creativeclouddeveloper.com/t/getentrywithurl/6453/12 "2023-06-30T12:12:47Z")

</div>

🤦 I still had the manifest version set to 4, rookie, rookie mistake
