Question: I have been using a folder object as part of a script written in javascript and used for photoshop cs6 scripting.

My question regards the folder object

The cs6 javascript referance document says the following about folder objects

> 
> "ExtendScript defines the JavaScript classes File and Folder to
>  encapsulate file-system references in a platform-independent manner;
>  see ‘JavaScript support in Adobe Photoshop CS6’ on page 32. For
>  references details of these classes, see the JavaScript Tools Guide."
> 
> 
> 

(ExtendScript is Adobe’s extended implementation of JavaScript)

I am able to set the Folders directory by using something similar to Folder.setDialogue (the code is on my other PC so I cant remember what the exact method is
but this prompts the user to select a folder.

I want to hard code the folder location into the script

the documentation says that the folder object accepts the folder as a constructor but i cant make this work

i have tried code which looks something like

Folder(c:/some folder) and have tried replacing none text characters with their hexadecimal values but this has not worked ether.

How do i make it work?

Answer: 
Something like: 

```
var myfolder= Folder("path/to/folder");
if(myfolder.exists) alert("got it");

```

Should work. Take a look at the extend script toolkit and the object model viewer under help
I too found this part of extendScript tricky and underdocumented.

Note that extendScript can express paths as URIs (escape all non-ascii!) and as system specific (Win/Mac - each of which have a different set of 'forbidden' characters).

The file object has two properties: `fullName` (a URI) and fsName (a file-system-specific path).

I *think* you have to pass a URI to the constructor, rather than a Windows/Mac path. So for: (Windows) `D:\foo\bar` use `/d/foo/bar`

Or you can get the open document file (if saved) as a starting point. This works for me in Illustrator:

```
var defaultFilename = "default.ai";
var fpath = app.activeDocument.fullName.path;
var myFolder = fpath || Folder.selectDialog ("Choose a Folder to export to");
if (myFolder === null) return

var myFilePath = myFolder + "/" + defaultFilename;
var myFile = new File(myFilePath).saveDlg("Export as", "Adobe Illustrator files:*.ai");
if (myFile === null) return
// if you get this far, myFile should be meaningful

```

Good luck!