14 Replies Latest reply on Aug 16, 2013 6:09 AM by Vamitul

    Location names changing

    rajnikids Level 1

      Hi Forum,

       

      I need a timely help, which will save hell lot of time for me..

       

      i have a script for relinking images.... distress i found is...

       

      after the images are linked in pc machine and when indesign files is opened in Mac ' The link address is mismatcing , hence i cant able to relink the images...

       

      How can the replace the first few lines in the image link path.....

       

      eg.... W:/9780630/983660/Linked/Car.jpg..... is the link information seen while checking in PC...

       

      trans/9780630/983660/Linked/Car.jpg..... is the link information seen after open the indesign file in mac... so,

       

      i want to replace W:/ with trans/ and then run my script to relink....

       

       

      var myFolder = Folder("trans/9780630/983660/Linked/");

      var new_path = myFolder+ '/'

      imgs = app.activeDocument.allGraphics

      for (i = 0; i < imgs.length; i++)

      {

       

      img = imgs[i].itemLink

       

      myFile = File (new_path + img.name);

       

      if (myFile.exists) {

      img.relink (File (new_path + img.name))

      img.update()

      alert (img.filePath);

      }

      }

       

      Many thanks

        • 1. Re: Location names changing
          Vamitul Level 4

          without testing, i guess this is your problem:

          var myFolder = Folder("trans/9780630/983660/Linked/");

          var new_path = myFolder+ '/'

           

           

          your new path becomes: trans/9780630/983660/Linked//

           

          fix: either  var myFolder = Folder("trans/9780630/983660/Linked");

               or use myFolder insead of new_path everywhere in your script.

          • 2. Re: Location names changing
            rajnikids Level 1

            Hi Vam, thanks thanks

             

            Many many apologise for the confusion..

             

            Actually, when i open the indesign document in PC" the links path of the links showned  as

             

            trans:/9780630/983660/Linked/Car.jpg

             

            When the indesign file is copied and pasted in a common server folder and opened in Mac machines...

             

            the link path is now: W:/9780630/983660/Linked/Car.jpg,  the link is missing, (W:/ is the mounted shortcut in PC machine where the links are placed from)

             

            so i want to replace W:/ with trans/ in a script to relink the image.... other path following trans:/ remains same.....9780630/983660/Linked/

             

            (the same Linked folder is copied and pasted in mac machine to relink, but not linking because of the link path changed trans:/ to W:/)

             

            Many thanks Vam...

            • 3. Re: Location names changing
              Vamitul Level 4

              not sure i understand all.. so let me see

               

              The script you posted in your first post is almost correct. The only problem that keeps it from working is that you added an extra "/" at the end of the relink path. chage this line:

              var myFolder = Folder("trans/9780630/983660/Linked/");

               

              to this:


              var myFolder = Folder("trans/9780630/983660/Linked");

               

              and it should work.

              • 4. Re: Location names changing
                rajnikids Level 1

                Ok Vam,

                 

                In my side, i'll again give a try and let you know..

                 

                thanks for your timely reply and support... vam.....

                 

                 

                many thanks vam....

                • 5. Re: Location names changing
                  rajnikids Level 1

                  Vam, otherwise,

                   

                  if the old link path could be whatevery it is..

                   

                  Could i able to replace the path of the first two instances, and then copy links....

                   

                  eg. the older link path is..Folder ("trans/9780630/983660/Linked/")

                   

                  and now the same link folder is available in the mounted disk: called: "volumes/studio/9780630/983660/Linked/"

                   

                  so I want to replace trans/ with volumes/studio/ and remaining the same path mathes...... relink and copy the files to the desktop folder"Linked"...

                   

                  thanks vam...

                  • 6. Re: Location names changing
                    Vamitul Level 4

                    just change the

                    var myFolder=Folder(bla bla

                    to

                    var myFolder= new Folder(app.activeDocument.filePath).selectDlg ("Select Root");

                     

                    and this should get you anywhere.

                    • 7. Re: Location names changing
                      rajnikids Level 1

                      Hi Vam,

                       

                      checked its workings, now if is for single file its fine.

                       

                      if regularly doing then i need to stick with this concept..

                       

                      i.e.  trans/jobno1/jobno2/Linked/xxxx.jpg  (pc machine path)

                           (common)/changing/changing/changing/xxx.jpg

                       

                          volumes/links/jobno1/jobno2/Linked/xxxx.jpg  (mac machine path)

                        (common)/common//changing/changing/changing/xxx.jpg

                       

                      so i'm want to input replace option in a script to find the link path if is  trans/bla/bla/bla and replace insid the script var myFolder("volumnes/links/" + "to retain here bla/bla" location)

                      file.relink(myFolder).

                       

                       

                      How to retain bla/bla location... checking the links pallette after the word trans/jobno1/jobno2/

                       

                      just a scrap thought i have, i dont know how to do it..

                       

                       

                      thanks sir....

                      • 8. Re: Location names changing
                        rajnikids Level 1

                        hi,

                         

                        string.indexOf("trans/").replace("volumes/links/");

                         

                        is this possible??

                         

                        many thanks,

                        • 9. Re: Location names changing
                          -hans- Level 4

                          PC_From_Mac you may try this one:

                          http://forums.adobe.com/message/4738618#4738618

                          Should work under explained circumstances.

                          1 person found this helpful
                          • 10. Re: Location names changing
                            rajnikids Level 1

                            hi -hans- thanks for stepping in..

                             

                            also this is from jongware..

                             

                            http://forums.adobe.com/message/4081745#4081745

                             

                            but i just want to know how to replace staring string in link path with some thing, which is found in your thread...

                             

                            '/Volumes/DTP/Produktbilleder/0893ny/0893_467+468_05_Agrp frit_.tif'.replace(/\/Volumes/, 'F:')

                             

                            here the exact link name is stated,

                             

                            but i do want to check all the links name and infront of it and to replace W:/ with /Volumes,

                             

                            as you said above..

                             

                            var myFolder = Folder("trans/9780630/983660/Linked/xyz.jpg");

                            .replace(/\/Volumes, 'trans'); how?

                            • 11. Re: Location names changing
                              rajnikids Level 1

                              However, thanks to Vam, for number of replies and patience in explaining me....

                               

                              thanks vam!!!!!!!!!..

                              • 12. Re: Location names changing
                                -hans- Level 4

                                additional ...

                                 

                                Guess you where just searching for the ability to to make custom-string-replace to combine it with the link-updating-script

                                 

                                 

                                //just replaces the searchsting, if the sourcestring starts with it!

                                String.prototype.pathReplace=function(toSearch, toReplace)

                                {

                                     toCheck = this.indexOf(toSearch);

                                  if(toCheck == 0)

                                  {

                                       newString = this.replace(toSearch, toReplace);

                                      return newString;

                                      }

                                  return this

                                    }

                                 

                                toSearch = 'oldString';

                                toReplace = 'newString';

                                 

                                pathToCheck = 'oldString/sample/sample';

                                 

                                 

                                alert(pathToCheck.pathReplace(toSearch, toReplace));

                                1 person found this helpful
                                • 13. Re: Location names changing
                                  rajnikids Level 1

                                  Very very usefull hint - hans-.....

                                   

                                  and very very usefull answer and clicked it for you -hans-...

                                   

                                  thanks for your support, fantastic J....

                                  • 14. Re: Location names changing
                                    Vamitul Level 4

                                    rajnikids, please check this out: http://forums.adobe.com/thread/1276902