6 Replies Latest reply on Nov 25, 2012 4:07 AM by Muppet Mark

    Want to Open File from the Path

    BEGINNER_X Level 3

      Hello,

       

      I am new to Indesing Scripting. Studying through "InDesignCS3_ScriptingGuide_JS" (page no 12).

       

      I am using Mas OS.

       

       

      My file saved in Desktop in the name "aa.indd". It open correctly.

       

      Running Sucessfully below code:

       

      var myOpen = app.open(File("~/Desktop/aa.indd"));

       

       

       

      But if i saved my file in "Macintosh HD/Users/Shared/TEST/aa.indd" or some other path it not open properly.

       

      Failure code is:

       

      var myOpen1 = app.open(File("Users/Shared/TEST/aa.indd)

       

      Please find the attachment.

       

      Kindly let me know in case of any clarification.

       

      Screen Shot 2012-11-23 at 7.24.35 PM.png

       

       

      Thanks in advance

      BEGINNER

        • 1. Re: Want to Open File from the Path
          Vamitul Level 4

          var myOpen1 = app.open(File("Users/Shared/TEST/aa.indd"));

           

          maby that is your problem?

          • 2. Re: Want to Open File from the Path
            Pickory Level 3

            I think you might also need.

             

            ~/user.........

             

            P.

            • 3. Re: Want to Open File from the Path
              [Jongware] Most Valuable Participant

              Your path is not correct. It's not what Pickory says, because your "Users" folder is not somewhere inside your local folder (which is indicated by the tilde). To use an absolute path, you have to start with a root folder:

               

              /Users/Shared/TEST/aa.indd

               

              .. This assumes the root folder of your Mac is called plain '/'. Can't test right now; it depends on your OS X version (? perhaps on local settings? time of day?), perhaps you have to start with /Volumes, or possibly with /siraj's\ Mac\ mini

               

              Anyway, it's the path that you supply that is wrong, and you should use the right one.

              • 4. Re: Want to Open File from the Path
                [Jongware] Most Valuable Participant

                A-ha, you don't even need to know the root path. This also works on Windows(!):

                 

                path = '~/../All Users';
                alert (Folder(path).getFiles().join('\r'));
                

                 

                i.e., the '~' directs you to your own root folder, and with '..' you navigate one 'level' up (so you are in the "Users" folder) and you can go down again into any other's Users folder.

                 

                So you could try this instead:

                 

                var myOpen1 = app.open(File("~/../Shared/TEST/aa.indd"));
                
                1 person found this helpful
                • 5. Re: Want to Open File from the Path
                  BEGINNER_X Level 3

                  Hi Jongware and All,

                   

                  It working fine.

                   

                  Thanks a lot!!!

                   

                  But i placed a file in different path(Application folder).

                   

                  It not works

                   

                  //var myOpen1 = app.open(File("~/Applications/TEST/aa.indd"));

                   

                  //var myOpen1 = app.open(File("~/../Applications/TEST/aa.indd"));

                   

                  //var myOpen1 = app.open(File("Macintosh HD/Applications/TEST/aa.indd"));

                  • 6. Re: Want to Open File from the Path
                    Muppet Mark Level 5

                    Your first one actually does work but you have placed your test… in the system level applications folder…

                     

                    // This one points to your current user account applications folder

                    // This is valid you just didn't put the file there…

                    var myOpen1 = app.open( File( "~/Applications/TEST/aa.indd" ) );

                     

                     

                    // This one points to your main system level applications folder

                    // These are apps available to all user accounts…

                    var myOpen1 = app.open( File( "/Applications/TEST/aa.indd" ) );