4 Replies Latest reply on Apr 19, 2016 2:23 AM by SubbaiyaArasu

    Alert Image if JobNumber not Match

    BEGINNER_X Level 3

      Hi All,

       

      I need to alert the image, where the operator link in different location (Both the Job Number need to match).

       

      Condition, Indesign File Path & Image File Path Job Number remains same.

       

      i.e.,

      Indesign File Path: /Volumes/JobProd/Print/01_LIVE/2016_04/Document/185000042_XXX_ULD Refresh TR

       

      Image Path: /Volumes/JobProd/Print/01_LIVE/2016_04/185000042_XXX_ULD Refresh TR/SS_LOGOS/5.12_EXR_1_TR.ai

       

       

      var myPath = app.activeDocument.filePath.fsName;
      var mJobNumber;  
        
      var reg = /(\/)([0-9]{8})(_)/;  
      if (myPath.match(reg)){  
          mJobNumber = RegExp.$2;  
      }  
      
      alert(mJobNumber)   //Working Fine
      
      var myGr = app.activeDocument.allGraphics;
      for(i=0; i<myGr.length; i++)
      {
          
          //Problem in below line
         if(myGr[i].itemLink.filePath.match(/mJobNumber/) == null)
         {
           app.select(myGr[i].parent)
           var check = confirm("Selected Images Link Path is Wrong\rDo you want to Continue?"+ "\n") 
          if (check == true)
          {  
              //Proceed Further
              }   
             else
             {  
                 exit(0);
                 }  
          }
      }
      

       

       

      Thanks in Advance

      Siraj

        • 1. Re: Alert Image if JobNumber not Match
          Chinnadk Level 4

          Hi Siraj,

           

          Place 9 inside the curly braces and try,

           

          var reg = /(\/)([0-9]{9})(_)/;

           

          Regards,

          Chinna

          • 2. Re: Alert Image if JobNumber not Match
            tpk1982 Level 4

            Siraj,

             

            I did this script long time before, use this.. need to remember the indesign and image should be in same folder.. but you can change as whatever you need in script

             

            //missing image path
            var theLinks=app.documents[0].links;
            var myPath = docRef.filePath;
            var currPath, i;
            var str = "";
            var stert="";
            var flag=0;
            for(i=0;i<theLinks.length;i++)
            {
            currPath=File(theLinks[i].filePath).path;
                if(currPath.indexOf(myPath)==-1){
                stert=str + (theLinks[i].filePath+"\n");
                flag=1;
                }
                }
            if(flag==1){
            alert("Images from different folder: "+"\n"+stert) }
            else{
            alert("No Images from different folder"+"\n"+stert);
            }
            
            • 3. Re: Alert Image if JobNumber not Match
              BEGINNER_X Level 3

              Thanks Chinna/Karthik for your timing help...

               

              As per your Regular expression changes, code is working fine..

              • 4. Re: Alert Image if JobNumber not Match
                SubbaiyaArasu Level 1

                I get some reference and tried this script for your requirement.

                 

                var doc = app.activeDocument; 
                var myPath = doc.filePath.fsName;
                var myGrp= doc.allGraphics;
                
                
                var jobIdLog="";
                var imgRootLog="";
                var mJobNumber;
                
                var reg = /(\/|\\)([0-9]{7,10})(_)/;
                if(myPath.match(reg)){
                      mJobNumber = RegExp.$2;
                  }
                
                
                checkImgValidation();
                writeLogFile();
                
                
                function checkImgValidation(){
                    for (var i =0; i<myGrp.length; i++){
                        var grPath=myGrp[i].itemLink.filePath;
                
                
                        if(grPath.indexOf(myPath)==-1){
                            imgRootLog+= "The Image not found in indesign root folder -- "+ grPath +"\r";  //art files should be in inDesign directory
                            }
                
                
                        if(grPath.indexOf(mJobNumber) == -1){
                            jobIdLog += "Art link path is wrong -- "+ grPath + "\r"; // job id match with indesign path
                            }
                        }
                }
                
                
                function writeLogFile(){
                    var fh=File(myPath+"\\ImageLog.txt"); 
                    fh.open("w");
                    fh.write(imgRootLog +"\r\r"+ jobIdLog);
                    fh.close()
                    }
                
                
                
                1 person found this helpful