Resolving the location of a script

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
mercwnz
Posts: 4
Joined: October 19th, 2010, 8:59 am

If you run alert(Folder.current) it shows you the location of the program that is currently executing the script.
What I rather see is the location of the script that has been executed.
Because if I want to include a XMLfile, I would like to use ../'s instead of the absoluteURI
my system wrote: Current Folderlayout

jsx (folder)
-thescript.jsx

php (folder)
-somescript.php
config.xml
so my problem is with php I can include the xml using include("../config.xml"),
but if I want to include something in jsx I have to use file.open("/c/full/path/to/config.xml")

I know how to generate a jsx file with php so the fullpath is hard-coded in there, but I rather not.
Is there a way to resolve the location of the script based on the location of the script instead of the program running it?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

$.fileName gives you the name and path of the running script. Here's some code to get the parent folder for the script:

Code: Select all

parentFolder = Folder(File($.fileName).parent)
mercwnz
Posts: 4
Joined: October 19th, 2010, 8:59 am

wow thanks, it was breaking my brain at some point!
Post Reply