Skip to main content
Participant
February 3, 2021
Answered

Help with executing a script from a script on mac OS

  • February 3, 2021
  • 2 replies
  • 772 views

Let me explain my situation. At my workplace, my coworker and I use Illustrator for printing purposes and I have written some scripts (.jsx) to make things easier. I use a windows computer and my coworker uses a mac. We have a network we use for sharing files between computers, so I thought creating a script to run the main script from the network would save lots of time in the event that I needed to make any changes going forward. I was successful when I made such a file for windows (shown below), but I've been having a lot of difficulty with making one for mac. I have tried different formats for the mac file path, but nothing I've tried has worked so far.

var scriptFile = new File("\\\\#.#.#.#\\Network Shared\\Illustrator Scripts\\Completed\\SetOverprint.jsx");
scriptFile.execute();

 

Any pointers to what I'm doing wrong are immensely appreciated.

This topic has been closed for replies.
Correct answer CNemo

I took a look at the article and changed my double backslashes for forward slashes. I ended up getting to a point where the path with the server address would work on windows but not mac, and the same path without the address would work on mac but not windows. From there, I just made it add the address to the path if the user was running windows and that seems to do the job.

var osVersion = $.os.substring(0,7);

if (osVersion == "Windows")
{
	pathOfFile = "//#.#.#.#" + pathOfFile;
}

 

2 replies

Inspiring
February 4, 2021

macOS natively uses POSIX file paths. Windows-style file paths will not work.

 

Read the JavaScript Tools Guide:

 

javascript-tools-guide.readthedocs.io/file-system-access/index.html

 

That explains how to construct paths that will work cross-platform. (The syntax is similar to that used in URLs.)

CNemoAuthorCorrect answer
Participant
February 4, 2021

I took a look at the article and changed my double backslashes for forward slashes. I ended up getting to a point where the path with the server address would work on windows but not mac, and the same path without the address would work on mac but not windows. From there, I just made it add the address to the path if the user was running windows and that seems to do the job.

var osVersion = $.os.substring(0,7);

if (osVersion == "Windows")
{
	pathOfFile = "//#.#.#.#" + pathOfFile;
}

 

rcraighead
Legend
February 4, 2021

-