5 Replies Latest reply on Sep 19, 2016 1:34 AM by Heimdaal

# Trying to get path of running JSX (\$.filePath not working)

I'm trying to get the location of the directory of the current script (main.jsx of my panel).
I've tried using \$.filePath without success...

Returns undefined or an int

var thisFile = new File(\$.fileName);

var thisFile  = new File(\$.fileName).parent;

What am I doing wrong?
I need to get the path of the running script file so I can do .parent to get it's folder name, and from there get a sibling folder name where I have some stuff to retrieve. I'm running this in my main.jsx -file.

• ###### 1. Re: Trying to get path of running JSX (\$.filePath not working)

Hi

Using this

```File(\$.fileName).fsName
```

you'll get  C:\Program Files\Adobe\Adobe Photoshop CC 2015\[scriptName.jsx]

Using this

```decodeURI(File(\$.fileName))
```

you'll get  /c/Program Files/Adobe/Adobe Photoshop CC 2015/[scriptName.jsx]

Or, to get the folder:

Using this

```File(\$.fileName).parent.fsName
```

you'll get  C:\Program Files\Adobe\Adobe Photoshop CC 2015

Using this

```decodeURI(File(\$.fileName).parent)
```

you'll get  /c/Program Files/Adobe/Adobe Photoshop CC 2015

You only need to use decodeURI() if not getting fsName, because fsName result is always decoded.

• ###### 2. Re: Trying to get path of running JSX (\$.filePath not working)

It's not working.
Using your first example, I get:

then the second time I use it I get

The number increments for each time I run the function where I have alert(File(\$.fileName).fsName);

• ###### 3. Re: Trying to get path of running JSX (\$.filePath not working)

Hi

Oh I have noticed just now that you are not putting your scripts in the scripts folder.

They should be here:

I have put a script jsx file in the photoshop scripts folder containing this:

and the alert came up with this:

• ###### 4. Re: Trying to get path of running JSX (\$.filePath not working)

That is correct - my scripts are located in the main.jsx of my panel.

So I guess that the \$.fileName function is rather dumb and not really working with panels. If this is indeed the case then is there another way of getting the path to the panel and/or script???

Also: I tried running alert(\$.fileName); in jsh* and then I got the correct path to the script So it appears that you only get this weird result when executing scripts from a panel.

*(a javascript shell. Google for Photoshop xtools and you'll find it - it's super-useful!)

• ###### 5. Re: Trying to get path of running JSX (\$.filePath not working)

Found the solution!

By running this code in the javascript file of your extension you will get the path:

```var csInterface = new CSInterface();
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/jsx/";