Copy link to clipboard
Copied
i'm trying to open a document from the same folder is the jsx file but its not working
Ok good. Where are you wanting the relative path to point to? The document? If so, then you can get the document path. From memory I think you can do:
app.activeDocument.fullName
to give you a file reference of the active document. You can then ask for the 'parent' which should give you the folder containing the file (see File object docs). Then ask for (I think) the 'fullName' of the parent to get it's path, then add your own filename, eg. 'fonte tamplate.ait". I hope that works for you.
this line gives you the full path of the current script. From there, you can convert it to a File Object and get it's Parent Folder.
alert($.fileName);
Copy link to clipboard
Copied
Very quick answer, and I'm probably wrong as I can't test it just now... try adding a period before the first slash in the path.
var fileRef = new File("./fonte tamplate.ait");
var docRef = app.open(fileRef);
I can't remember if I've ever used a relative path like this. And I'm not sure what it would be relative to. You could test be writing a text file there perhaps? Also, does your code work with a full path?
Copy link to clipboard
Copied
try adding a period and its still not working and yes it does work with a full path like these
var fileRef = new File("~/Downloads/fonte tamplate.ait")
var docRef = app.open(fileRef);
but i need to deliver those script to customers so it have to be at the same folder
Copy link to clipboard
Copied
Ok good. Where are you wanting the relative path to point to? The document? If so, then you can get the document path. From memory I think you can do:
app.activeDocument.fullName
to give you a file reference of the active document. You can then ask for the 'parent' which should give you the folder containing the file (see File object docs). Then ask for (I think) the 'fullName' of the parent to get it's path, then add your own filename, eg. 'fonte tamplate.ait". I hope that works for you.
Copy link to clipboard
Copied
this line gives you the full path of the current script. From there, you can convert it to a File Object and get it's Parent Folder.
alert($.fileName);