0 Replies Latest reply on Aug 12, 2013 8:44 AM by davidDav

    Relink Missing LINKS

    davidDav

      Hi All,

       

      I am converting IDML to INDD from Windows to Windows, script running in MAC like watched folder IN and OUT, my files are converting good.

       

      When I opened after the converted, the files having missing FONTS and LINKS though the server connnected. I fixed UPDATED LINKS, but i can't fix MISSING LINKS

       

      how can i find missing links path, and relink it the same path. forum please help me.

       

       

      checkDocLen()
      var myDoc;
      
      var mySourceFolder = Folder("/SERVER/WATCHED_FOLDER/IDML");
      var myOutFolder = Folder("/SERVER/WATCHED_FOLDER/OUT");
      
      var Idml_files = get_File(mySourceFolder,[],'.idml');
      
      if(Idml_files.length>0)
      {
          for(var w=0;w<Idml_files.length;w++)
          {
              try{
                  app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                  myDoc = app.open(File(Idml_files[w]));
                  app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                  var myDocNam = stripExt((Idml_files[w].name).replace(/%20/g," "))+"indd";
                  myDoc.save(File(myOutFolder+"/"+myDocNam));
                  app.activeDocument.close();
              }catch(E){}
          }
      }
      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      function get_File(dir,myfile_arr,extension) 
      {
          var f = Folder( dir ).getFiles(); 
          for( var ifil = 0; ifil < f.length; ifil++ ) 
          {
              var mystr=f[ifil]+"";
              var aa=mystr.match(/\/[.]AppleDouble/)
              var bb=mystr.match(/[_]VUC69~7/)
              var cc=mystr.match(/DS[_]Store/)
              
              if( f[ifil] instanceof Folder )     //change
              {
                  if((aa==null) && (cc==null))
                  {
                      get_File( f[ifil],myfile_arr,extension) 
                  }
              }
              else 
              {
                  if(extension!=".*") 
                  {
                      if( f[ifil].name.substr( -extension.length ) == extension ) 
                      { 
                          myfile_arr.push(f[ifil])
                      }
                  }
                  else 
                  {
                      if((bb==null) && (cc==null) && (f[ifil] instanceof Folder == false))
                      {
                          myfile_arr.push(f[ifil]);
                      }
                  }
              }   
          }//for
          return myfile_arr;
      }
      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      function stripExt (f) 
      {   
              return f.substring(0,f.length-4);   
      }
      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      function checkDocLen()
      {
          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
          while(app.documents.length!=0)
          {
              try{
                  app.activeDocument.close();
              }catch(e){}
          }
      }
         
      try {
      var myDoc = app.activeDocument;
          updateLinks();
      
      function updateLinks(){
          for(var myCounter = myDoc.links.length-1; myCounter >= 0; myCounter--){
          var myLink = myDoc.links[myCounter];
              if (myLink.status == LinkStatus.LINK_OUT_OF_DATE){
                  myLink.update();
              }
          }
      }
      }catch (e){}
      

       

       

      Thanks

      David