6 Replies Latest reply on May 25, 2016 2:05 AM by Peter Kahrel

    Copy links to page specific direcotry

    rz67162887

      Hello,

       

      I need a basic script, but I don't have any experience with js/scripting.

      Could anyone help me?

       

      It's very basic task:

       

      I need to copy all my links, to page numer specific directory...

       

      So it's basically:

      1. select all links on page

      2. command "Copy links to..."X" where X is the page numer.

       

      Thanks in advance

        • 1. Re: Copy links to page specific direcotry
          Peter Kahrel Adobe Community Professional & MVP

          Two things to keep in mind: (1) when you write up a post for a forum, before sending it, read it back and try to understand what you wrote a few minutes earlier; (2) if you don't know much about scripting, don't assume that what you ask is simple.

           

          Peter

          • 2. Re: Copy links to page specific direcotry
            rz67162887 Level 1

            You are not very helpfull...

             

            Task is simple, not the code. I'm php coder, so I have "some" knowledge about programming in general, but this is different and I don't have any experience with Indesign scripting.

            • 3. Re: Copy links to page specific direcotry
              Peter Kahrel Adobe Community Professional & MVP

              If you know php, then you shouldn't have too many problems with JavaScript.

               

              This:

               

              "I need to copy all my links, to page numer specific directory...

              So it's basically:

              1. select all links on page

              2. command "Copy links to..."X" where X is the page numer."

               

              Is not so clear. You want to select the links on e.g. page 5. Is there a directory called '5'? And where is that directory? Is it a sub-directory of the document's directory? And you want to copy the images from wherever they are to 5. Should the links be updated to point to the new location of the images?

              • 4. Re: Copy links to page specific direcotry
                rz67162887 Level 1
                You want to select the links on e.g. page 5.

                 

                Yes

                 

                Is there a directory called '5'?

                Whatever - I can create it. It's not so important here.

                 

                 

                And where is that directory?

                Wherever...

                 

                Is it a sub-directory of the document's directory?

                It can be.

                 

                And you want to copy the images from wherever they are to 5.

                Yes

                 

                Should the links be updated to point to the new location of the images?

                No

                • 5. Re: Copy links to page specific direcotry
                  Peter Kahrel Adobe Community Professional & MVP

                  Here's something to get you started.

                   

                  if (app.selection == null) exit();
                  for (i = app.selection.length-1; i >= 0; i--) {
                    if (app.selection[i] instanceof Rectangle && app.selection[i].graphics.length > 0) {
                      try {
                        app.selection[i].graphics[0].itemLink.copyLink (Folder('/d/test'));
                      } catch (e) {
                        $.writeln (e.message);
                      }
                    }
                  }
                  

                   

                  P.

                  • 6. Re: Copy links to page specific direcotry
                    Peter Kahrel Adobe Community Professional & MVP

                    Forgot about the page-specific directory. Probably confused by the vagueness of whatever and wherever, but here you go:

                     

                    if (app.selection == null) exit();
                    
                    for (i = app.selection.length-1; i >= 0; i--) {
                      if (app.selection[i] instanceof Rectangle && app.selection[i].graphics.length > 0) {
                        try {
                          dir = app.selection[i].parentPage.name;
                          app.selection[i].graphics[0].itemLink.copyLink (Folder('/d/test/'+dir));
                        } catch (e) {
                          $.writeln (e.message);
                        }
                      }
                    }
                    

                     

                    If you have a page item, its parentPage is a page, and the page's name is the displayed page number.

                     

                    P.