Skip to main content
Participating Frequently
July 12, 2011
Answered

Apple/Mac Appending to File path?

  • July 12, 2011
  • 2 replies
  • 1706 views

I have the following javascript script runnning in InDesign:

if (File.fs == "Windows") {

var defaultPath = new File('\\\\server\\path\\to\\file');

} else {

var defaultPath = new File('smb://server/path/to/file');

}

The code works fine in Windows (the file is on a Windows shared directory), but on a Mac I get a "cannot find folder" error and claims the defaultPath variable is:

/Applications/Adobe InDesign CS5/scripts/XHTML For Digital Editions/smb:/server/path/to/file

I am confused about 2 things:

  1. Why is it appending "/Applications/Adobe InDesign CS5/scripts/XHTML For Digital Editions/" to the path?
  2. Why is it changing smb:// to smb:/ (one forward-slash) ?

Am I using the wrong path for Mac? Is there supposed to be something else before smb:// to identify that it is not a local path?

This topic has been closed for replies.
Correct answer JohnDevlon

Hi James,

On a mac you have to acces a network volume as follows...

                var myTxtFile = File("/volumes/MountedShareName/test.txt");

                myTxtFile.open("w");

                myTxtFile.write("Test\n");

                myTxtFile.close();

                alert("Done");

This example writes a test file to a mounted network volume...

Hopes this helps...

John

2 replies

JohnDevlonCorrect answer
Inspiring
July 12, 2011

Hi James,

On a mac you have to acces a network volume as follows...

                var myTxtFile = File("/volumes/MountedShareName/test.txt");

                myTxtFile.open("w");

                myTxtFile.write("Test\n");

                myTxtFile.close();

                alert("Done");

This example writes a test file to a mounted network volume...

Hopes this helps...

John

Participating Frequently
July 12, 2011

John,

As I stated in my first reply, using /Volumes/ did not work

I am not sure the path specified is mounted on the system. Is that required and how do you get the mount name? Is it possible to access the path without it being mounted?

I was also looking here:

http://support.apple.com/kb/HT2799

Will /Network/Servers etc work?

I am not a Mac user so I don't know much about Mac's filesystem or the file paths used. On the test machine I have used just typing in smb://server/path/to/file works in the Finder (Windows Explorer equivalent) but does not work in the code.

Inspiring
July 12, 2011

Hi James,

Strang. It worked fine for me. I don't think you can acces a network volume before its mounted. Maybe it's case sensitive. Did you check if "volumes" is all in lower case?

What I would do is to check if the volume is mounted or not. You also could throw a display dialog window to let the user select the network location. Then you know for sure that the share is mounted and exists.

Hopefully this helps

John

Participating Frequently
July 12, 2011

A bit of searching produced this:

http://forums.adobe.com/thread/516636

Using /Volumes/server/path/to/file did not work either.

At least it did not append anything to the beginning of the path.