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

$.fileName will not work in script in OS X

Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

I'm using a script which stores its Prefs in the script folder. But it does not work in my case, the file will not be created. It does not get a path where to build it, so no file is being stored.

I gave Illustrator full hard drive privileges already, but the script will not throw the script path.

 

var scriptPath = (new File($.fileName)).path 

will throw "",  with alert just an empty field

 

var scriptName = (new File($.fileName))

will throw /3 with alert (scriptName)

 

Any idea, why the script will not get it's path?

app.path will throw the rigth path to the app ...

 

TOPICS
Bug , Scripting

Views

843

Translate

Translate

Report

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

Participant , Dec 16, 2023 Dec 16, 2023

@GNDGN @m1b @Sergey Osokin Oh f*** I got the issue!

I use a plugin called "Scripts Panel" to organize my scripts, as Adobe offers such a freaky script menu (actually from two different developers) and each of these break exactly this one code!

 

Starting the script with Illustrator menu it will make it run!

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Hi @Someone75, it works as expected for me on MacOS 14.2, Illustrator 28.0.

 

What do you get when you run the script file from your Desktop? If it works on Desktop, maybe look at the permissions on the "script folder" you mentioned. Could they be restrictive? It doesn't seem likely, because it wouldn't run at all if you didn't have read access, and you shouldn't need write access in your example script.

 

Hmm. Can you try this test code, just to rule out code issues:

(function () {

    alert($.fileName);

})();

- Mark

Votes

Translate

Translate

Report

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
Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

@m1bI ran your script from desktop and it throws "3" ...

Votes

Translate

Translate

Report

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
Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

...it throws 3 twice?

Votes

Translate

Translate

Report

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 ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Very curious. Again, just to rule out possibilities, can you do this?

 

1. Restart computer.

2. Launch Illustrator

3. Run my script (do not run any other script first).

- Mark

 

P.S. Trivial point that affects nothing, so I hope you don't mind me saying,  just for learning: in many programming contexts (including ExtendScript) the term "throw" means throwing an exception (an error). In this case the alert function is showing "3", not throwing "3". You would say a function returns "3", not throws "3".

Votes

Translate

Translate

Report

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
Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

Sorry for the wrong term. As it does not work on two different machines, the restart did not address the issue ...

It's so wired. Even the "/3" alert. Where dos the 3 come from? It will always be three, no other number. ...

Votes

Translate

Translate

Report

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 ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

Yes, it's really very strange. Do you use VSCode and ExtendScript Debugger? It would be interesting to see if the script worked correctly when run from VSCode, and also to look at $ object in the debugger.

- Mark

Votes

Translate

Translate

Report

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
Participant ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

No I just use Illustrator and Sublime. No debuggers at hand ...

Votes

Translate

Translate

Report

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
Participant ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

You can use this package for basic ExtendScript debugging via ST:

https://github.com/rendertom/Sublime-Text-Adobe-Script-Runner 

____________________
Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5

Votes

Translate

Translate

Report

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
Participant ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

@GNDGN @m1b How wired is this?

Thaks a lot @GNDGN for the debugging package. So I started the script from sublime fodler and what happened?

The debugger opened Illustrator and I got the right pathes!

/Applications/Adobe Illustrator 2024/Presets.localized/de_DE/Skripten/

Bildschirmfoto 2023-12-16 um 14.16.28.jpg

 

Than I ran the skript manually from Illustrator and what happened?

The wrong output. What that, how is this possible?

Bildschirmfoto 2023-12-16 um 14.16.47.jpg

Votes

Translate

Translate

Report

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 ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

Another test (without much hope):

alert($.reflect.properties);

alert(""
    + app.version
    + '\n' + $.fileName
    + '\n' + $.os
    + '\n' + $.engineName
    + '\n' + $.includePath
);

 

By the way, it is the $.fileName that is returning "3" that is the problem. If you do

alert(new File("3"));

 you will get "/3".

- Mark

Votes

Translate

Translate

Report

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
Participant ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

@mb1 Starting your script with Extend Script debugger in Sublime I get these informations:

error,version,build,buildDate,global,stack,level,flags,strict,locale,localize,decimalPoint,memCache,appEncoding,screens,os,fileName,line,hiresTimer,dictionary,engineName,includePath,__proto__

 

Bildschirmfoto 2023-12-16 um 14.23.59.jpg

 

 

starting it manually I get:

Bildschirmfoto 2023-12-16 um 14.26.05.jpg

Votes

Translate

Translate

Report

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
Participant ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

@GNDGN @m1b @Sergey Osokin Oh f*** I got the issue!

I use a plugin called "Scripts Panel" to organize my scripts, as Adobe offers such a freaky script menu (actually from two different developers) and each of these break exactly this one code!

 

Starting the script with Illustrator menu it will make it run!

Votes

Translate

Translate

Report

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
Participant ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

Thanks for resolving this exciting episode. 😉

____________________
Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5

Votes

Translate

Translate

Report

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
Participant ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

@GNDGN It was only possible because of your help! I would never, ever have expected this root cause ... on two different machines with different plugins and same error type ... really strange.

Votes

Translate

Translate

Report

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 ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

Excellent! Nice to have the cause discovered. I notice someone has posted as a bug on the github repo (maybe you!). Hopefully the developer can fix it. The code seems to evaluate the script through BridgeTalk I think. Maybe they can manually set $.fileName if the bridgeTalk route doesn't set it automatically? We'll see.

Votes

Translate

Translate

Report

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
Enthusiast ,
Dec 16, 2023 Dec 16, 2023

Copy link to clipboard

Copied

I use this extension: Scripshon Trees https://exchange.adobe.com/apps/cc/15873/scripshon-trees.

Votes

Translate

Translate

Report

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
Participant ,
Dec 17, 2023 Dec 17, 2023

Copy link to clipboard

Copied

@Sergey OsokinI tested this script, too, but as a designer: It looks so old old old fashioned. I cannot use it without tears in my eyes, because of the uggly interface ... 😭

Votes

Translate

Translate

Report

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
Enthusiast ,
Dec 17, 2023 Dec 17, 2023

Copy link to clipboard

Copied

Appearance vs. functionality 🙂 Having a search box in Scriptshon Trees is important to me because I have a lot of scripts and some I run in the search results by first letters. Also, Scriptshon has a better view of the tree structure of the catalogs. In the Scripts panel, there is no tabulation and all catalogs and scripts in them are displayed in a single list. This is my subjective perception.

 

But I give credit to the fact that the Scripts panel has Live Input and Load Remote Script, which are important chips. So I installed both extensions.

 

Votes

Translate

Translate

Report

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
Advocate ,
Feb 14, 2024 Feb 14, 2024

Copy link to clipboard

Copied

LATEST

Thanks for confirming this, I had an issue with a script I made a dialof for. One user also had this issue, after lots of messages back and forth. I believe we came to the same issue.

Votes

Translate

Translate

Report

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
Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

The read and write permissions of the script folder must be assigned to the user who is executing the script. (https://support.apple.com/guide/mac-help/mchlp1203/mac)

 

With the correct permissions, this test is running successfully for me:

var scriptPath = new File(File($.fileName).path + "/test.txt");

scriptPath.encoding = "utf-8";
scriptPath.open("w");
scriptPath.write("Hello world!");
scriptPath.close();

 

____________________
Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5

Votes

Translate

Translate

Report

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
Participant ,
Dec 14, 2023 Dec 14, 2023

Copy link to clipboard

Copied

I know that it works for most others. My question was actually, why it does not work in my case on two different machines.

Permissions are set right, as app.path will work quite well and I run the script from Desktop.

Your skript does not work in my case, too. The generated path is /test.txt

 

Anyway I do not know which other permissions I would have to set. Illustrator hast full hard disk access and I (the current user) have access like all admins. I can read and write to all non-system restricted folders.

Votes

Translate

Translate

Report

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
Enthusiast ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

We are testing English localizations. But in another thread I saw your de_DE/Skripten path. Maybe we should look at different localizations of Adobe Illustrator on macOS? Or maybe macOS itself is German and this is the problem with $.filename in ExtendScript. 

 

Because yesterday I had an update to macOS 12.7.2 without script path errors. English macOS, en_GB localization of Adobe Illustrator.

Votes

Translate

Translate

Report

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
Participant ,
Dec 15, 2023 Dec 15, 2023

Copy link to clipboard

Copied

@Sergey OsokinMeanwhile I think it's exacrly what you write:The German OS and German Illustrator. As all other terms work, this is the only reason I could think of at the moment.

Updatet to 12.7.2 but it did not change the results.

alert($.fileName) >> 3


alert(new File($.fileName)
>> /3

Votes

Translate

Translate

Report

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 ,
Dec 18, 2023 Dec 18, 2023

Copy link to clipboard

Copied

@jduncan I wondered if this thread might be relevent to your AI Command Palette project?

- Mark

Votes

Translate

Translate

Report

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