Copy link to clipboard
Copied
Hi guys,
I was trying to find the current folder, but I couldn’t 😕
Folder.Desktop = Desktop (Win and Mac)
My little question is:
- How can I send to JavaScript the current folder?
(No path, just the folder where I am woking on to use external .jsx files)
Many thanks in advanced!
var myPath = $.fileName.substring(0,$.fileName.lastIndexOf('/'));
alert(myPath);
Copy link to clipboard
Copied
edit.. woops. i totally misread the question.
what's the end goal? you want to point to a particular folder that's holding the JSX file? Or you want to point a particular JSX file to an illustrator file and run the script on that file?
Copy link to clipboard
Copied
For now, at work I can’t install anything and have to run my .jsx file from my USB.
Ex… saveFiles,jsx file is the main form that runs the toEPS.jsx file in the same folder
witch contains binary code.
I try to do this to protect some files… because of this, I would like to know how to
get Current Folder instead of a full path (H:\Folder\Folder)
Copy link to clipboard
Copied
i guess I'm still misunderstanding. what is the current folder you're looking for? the folder that contains the active illustrator document? or the folder that contains the jsx?
are you just looking for the name of the folder for some type of validation? If not, in order to do anything with that folder you're going to need the whole path (or at least a relative path).
can you give me a list of steps you're looking to accomplish? perhaps that will clarify for me, so I can be of more help.
Copy link to clipboard
Copied
I think you kind-of have to have a full or relative "path" to get any folder, by definition. To have current script's location, etc, you can use $.fileName to get he script's path, and you can also use $.includePath to get the folder, theoretically. Let me know if it works!
Copy link to clipboard
Copied
Hi guys_
Using "$.fileName" I can extract the "path" + "fileName"
- Ex: C:\Test\myFile.jsx
But I just need to extract the path, not the file name and extension.
- Ex: C:\Test\
Thanks my bros!
Copy link to clipboard
Copied
var myPath = $.fileName.substring(0,$.fileName.lastIndexOf('/'));
alert(myPath);
Copy link to clipboard
Copied
Workeeed xD
Many thanks crack... many thanks!
Copy link to clipboard
Copied
Credit goes to Silly-V
all I did was apply a simple inbuilt function of javascript to his solution.
in addition to substring I would familiarize yourself with substr and maybe regex.
Copy link to clipboard
Copied
Yeah, you right Qw... respect (Y)
Many thanks for your help... All of you know a lot of programming.
Hugs!
Qw... I will give a try to the website you recommended to me for extensions... regards!
Copy link to clipboard
Copied
most of what I know I learnt here on the forums.
and having a brain that can't leave a question unanswered helps.
there are some great tutorial/lectures on youtube about javascript.
granted they are directed at web programming but the idea is the same.
I found this one quite enlightening...
JavaScript: Understanding the Weird Parts - The First 3.5 Hours - YouTube
Find more inspiration, events, and resources on the new Adobe Community
Explore Now