6 Replies Latest reply on Jul 12, 2011 9:15 AM by John Hawkinson

    Apple/Mac Appending to File path?

    James Robinson Level 1

      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?

        • 1. Re: Apple/Mac Appending to File path?
          James Robinson Level 1

          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.

          • 2. Re: Apple/Mac Appending to File path?
            JohnDevlon Level 1

            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

            • 3. Re: Apple/Mac Appending to File path?
              James Robinson Level 1

              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.

              • 4. Re: Apple/Mac Appending to File path?
                JohnDevlon Level 1

                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

                • 5. Re: Apple/Mac Appending to File path?
                  James Robinson Level 1

                  John,

                  I tried in on another system and it worked. I think there is another issue though. It looked like it starts from the mount point of the volume.

                   

                  So if one person has volume "myshare" mounted from "smb://myshare/path/to" and another person has volume "myshare" mounted from "smb://myshare" the path to the file will be different!

                   

                  On the former's computer the path to the file would be '/Volumes/myshare/file" whereas the latter's path would have to be "/Volumes/myshare/path/to/file"

                   

                  This is going to get tricky...

                   

                  Thanks for your help!

                  • 6. Re: Apple/Mac Appending to File path?
                    John Hawkinson Level 5

                    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.

                    It looks like this is getting complicated, but you may find it easier to use Applescript to tell the Finder to mount the volume for you.