Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Current folder?

Explorer ,
Oct 27, 2015 Oct 27, 2015

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!

TOPICS
Scripting
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 27, 2015 Oct 27, 2015

var myPath = $.fileName.substring(0,$.fileName.lastIndexOf('/'));

alert(myPath);

Translate
Adobe
Community Expert ,
Oct 27, 2015 Oct 27, 2015

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2015 Oct 27, 2015

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2015 Oct 27, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 27, 2015 Oct 27, 2015

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2015 Oct 27, 2015

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2015 Oct 27, 2015

var myPath = $.fileName.substring(0,$.fileName.lastIndexOf('/'));

alert(myPath);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2015 Oct 27, 2015

Workeeed xD

Many thanks crack... many thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2015 Oct 27, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2015 Oct 27, 2015

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 27, 2015 Oct 27, 2015
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines