3 Replies Latest reply on Jan 14, 2015 7:09 PM by RobertKyle

    Upon Open » Open possibe? if not=open as copy!

    DBLjan Level 2

      Hello,

       

      I hope someone has bugged this already and has a smart script, that helps doing this:

       

      Mostly I browse on networkvolumes by finder, wanting to open InD-docs, shared with my collegues. Commonly we have a bunch of documents open, so it happens I come along finder-browsing to a document, which is already opened by my collegue (which doesnt works near me). Doublclicking this lets InD error ~"Already open by someone".

       

      I imagine a startup-script who listen eventwise on open (even by doubleclicking in finder or dragdropping onto the doc), if that fails because its already open by someone else, then open the doc AS COPY.

       

      I guess someone did this already…

        • 1. Re: Upon Open » Open possibe? if not=open as copy!
          RobertKyle Level 2

          I don't have such a script, but here's a snippet that might help you get started:

           

          var beforeOpenListener = app.addEventListener("beforeOpen",beforeOpenTest);

          beforeOpenListener.name = "beforeOpenTest";

           

          function beforeOpenTest(theTarget) {

              a = theTarget.fullName;

          } //end function;

           

          which creates the event listener and captures the path to the file that's about to open.

           

          So now the question is how can the function determine whether the file is in use by someone else.

          Maybe you could test the parent folder for a .idlk file. Or maybe just "try" to open the file and trap whatever error InDesign throws when the file is in use.

          • 2. Re: Upon Open » Open possibe? if not=open as copy!
            DBLjan Level 2

            Thanks for your help, but I'm just a bit expirienced in using AppleScript, can't JavaScript a thing…but maybe we can achiev this together.

            I can image this could work, but I dont know the JS-syntax:

             

            AFTER OPEN check if open window FILENAME exist. If not, OPEN filename AS COPY.

            • 3. Re: Upon Open » Open possibe? if not=open as copy!
              RobertKyle Level 2

              Sorry, I just don't know any more about it.

               

              But if you're on a Mac, I'm sure you can set up an event listener in AppleScript. The last AS I wrote predated event listeners, so I don't have any examples.

               

              I also seem to recall that there were some Finder commands that could get at the question of whether a File is busy.