18 Replies Latest reply: Sep 20, 2011 8:10 AM by KevinPowell_Art RSS

    Windows Servers - JavaScript

    KevinPowell_Art Community Member

      It whindows, What is the proper way to access the file location via JavaScript.

       

      I am trying to open a file from server then save to server. But it is not opening the file.

       

      Thanks

        • 1. Re: Windows Servers - JavaScript
          KevinPowell_Art Community Member

          var myDocument = app.open(File("FILE STRUCTURE HERE"/thumbnail_array.indt"));

           

          The server file structure is the code I am fighting with. What is the proper way to write this?

          • 2. Re: Windows Servers - JavaScript
            Harbs. CommunityMVP

            Can you post an example of what you tried?

            • 3. Re: Windows Servers - JavaScript
              Harbs. CommunityMVP

              The easiest way to get that is to browse for the file in ESTK and check the URI (or native path).

               

              File.openDialog("gimme a file");

              • 4. Re: Windows Servers - JavaScript
                reddirt66

                I'll have to get the example file and post it tomorrow.

                 

                openDialog defeats the purpose of the script so that is not an option. If I wanted people searching for files I would just have them search for files and keep moving them into wrong places.

                 

                I was simply looking for the filing structure for windows because it is not clearly documented. Eithere poit toward some documentation or some quick example code. Mac on the other hand works like a charm. Unfortunately I have to work off of the windows server. works fine through the local windows machine but is having problem accessing the network.

                 

                I would just like to see how you are suppose to write the path and I'll fill in the rest:

                 

                var myDocument = app.open(File(PATH+"thumbnail_array.indt"));

                 

                PATH for a windows server is all I am looking for.

                • 5. Re: Windows Servers - JavaScript
                  Harbs. CommunityMVP

                  My point was not to include File.openDialog() in the script.

                   

                  My point was for you to use it to browse what the path appears in the File object.

                   

                  Harbs

                  • 6. Re: Windows Servers - JavaScript
                    Haakenlid Community Member

                    Try to run this. It'll show the path of the file you select in the dialog.

                     

                    alert(File.openDialog("gimme a file").fullName);
                    
                    • 7. Re: Windows Servers - JavaScript
                      reddirt66 Community Member

                      I have tried both of those methods and it works for the Mac and not Windows. Neither method helped which is what I ask the simple question - How would you write it if you were connecting to a windows server?

                       

                      Thanks for the responses and I will provide an example in a couple of hours.

                      • 8. Re: Windows Servers - JavaScript
                        Haakenlid Community Member

                        reddirt66 wrote:

                         

                        I have tried both of those methods and it works for the Mac and not Windows. Neither method helped which is what I ask the simple question - How would you write it if you were connecting to a windows server?

                         

                        Thanks for the responses and I will provide an example in a couple of hours.


                        How did the openDialog() method fail in windows? Did you get an error message?


                        Something like this should work if you get the correct filepath, and you should be able to find the correct filepath by using openDialog();

                        var myDocument = app.open(File("/D/folder/subfolder/thumbnail_array.indt"));
                        
                        • 9. Re: Windows Servers - JavaScript
                          KevinPowell_Art Community Member

                          This was my first attempt (I also tried the // between each and \

                           

                          var myDocument = app.open(File("/F/Atlfs01/groups/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/thumbnail_array.indd"));

                           

                          This is what openDialog gave me:

                          //Atlfs01/groups/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/thumbnail_array.indd

                           

                          var myDocument = app.open(File("//Atlfs01/groups/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/thumbnail_array.indd"));
                          • 10. Re: Windows Servers - JavaScript
                            Harbs. CommunityMVP

                            Okay. Now we have some info...

                             

                            You are talking about a mounted network volume. You did not state that earlier. I have no experience with mounted Windows network volumes. How would you address a file using the command prompt in Windows?

                             

                            Try removing the extra forward slash before Atlfs01.

                             

                            Harbs

                            • 11. Re: Windows Servers - JavaScript
                              KevinPowell_Art Community Member

                              Thanks Harbs, I have also removed the extra forward slazh with no avail.

                               

                               

                              This is the command prompt:

                              \\Atlfs01\groups\AssetManagement\Public\Projects_Products\Image Library\~Article Thumbnails\~THUMBNAIL_TEMPLATES

                              • 12. Re: Windows Servers - JavaScript
                                Haakenlid Community Member

                                Seems like there could be several things that could cause problems.

                                 

                                There is an extra space beween "u" and "c" in  "Projects_Produ cts", is that in your script as well

                                 

                                Is your file INDD or INDT?

                                 

                                Are the ~ characters part of the folder names? It seems unusual. That is often a reserved character in paths.

                                 

                                Can you try to put the indesign file in the folder "groups". If you can reach it there, the problem must be somewhere later in the path string.

                                 

                                Sometimes you need to replace spaces in file paths with "%20", that might be worth a try.


                                If you have the correct path you can check if  File("path").exists === true, that's simpler than trying to open it with indesign.

                                • 13. Re: Windows Servers - JavaScript
                                  Marijan Tompa MeganK

                                  Kevin,

                                   

                                  Try this:

                                   

                                  var myDocument = app.open(File("\\\\Atlfs01\\groups\\AssetManagement\\Public\\Projects_Products\\Image Library\\~Article Thumbnails\\~THUMBNAIL_TEMPLATES\\temps\\thumbnail_array.indd"));

                                   

                                  Hope that helps.

                                   

                                  --

                                  Marijan (tomaxxi)

                                  http://tomaxxi.com

                                  • 14. Re: Windows Servers - JavaScript
                                    KevinPowell_Art Community Member

                                    Thank you for the File("path").exists === true test... I am just going through options. The space was not there and %20 did not work as well.

                                     

                                    Using exists to test options

                                    • 15. Re: Windows Servers - JavaScript
                                      KevinPowell_Art Community Member

                                      It reads the file at the root level but not any further. I think it is a permissions issue.

                                      • 16. Re: Windows Servers - JavaScript
                                        Haakenlid Community Member

                                        If you can open the file using openDialog(), then it should not be a permission issue.

                                        I suspect that the tilde (~) in the folder name might cause problems.
                                        It's often used as substutition for the User folder in windows. like this: Folder("~/Desktop"), which points to the desktop folder of the currently logged in user.

                                         

                                        But that's just a guess. If you have permission to rename the folders with tilde I would give it a try.

                                        • 17. Re: Windows Servers - JavaScript
                                          KevinPowell_Art Community Member

                                          File("/S/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/array_template.indd").exists === true

                                           

                                          The group name was causing issue.

                                           

                                           

                                          THIS WORKS - THANK YOU EVERYONE!!!

                                           

                                           

                                          This also works

                                          File("S:/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/array_template.indd").exists === true

                                          • 18. Re: Windows Servers - JavaScript
                                            KevinPowell_Art Community Member

                                            Issue 2 came up where some computers had it mapped to a different drive letter. I retested with the group name and the / and it works now,

                                             

                                             

                                            File("//Atlfs01/groups/AssetManagement/Public/Projects_Products/Image Library/~Article Thumbnails/~THUMBNAIL_TEMPLATES/temps/array_template.indt").exists === true

                                             

                                             

                                            Thanks Again