12 Replies Latest reply on Aug 1, 2011 10:11 PM by csm_phil

    Help me!!!!!!!!

    Bhatt, Manish Level 1

      HI

       

       

      var Doc = app.activeDocument;
      var myDocName = Doc.name.split(".")[0];
      var parentFolderName = String(Doc.filePath).split("/").pop()
      if(myDocName==parentFolderName)
      alert ("Yes, your file name and folder name are same")
      else
      alert ("No, your file name and folder name are different")

       

       

      please you can also help me on this script

       

      if my file name is US_001-002_opener

       

      and my folder name is 001-002_opener

       

      i can only check a page number range and hyphen

       

      for example

       

      001-002

      001_002

       

      write one is 001-002

       

      I can run the script on batch and generated a error log on text file which file name not match and folder name also not match

       

      can you help me?

        • 1. Re: Help me!!!!!!!!
          csm_phil Level 4

          Hi Manish,

           

          I have created the script for your above mentioned request. This script is only run in the open indesign document only if you need batch you can able to update the script otherwise i will support to create.

           

          This is script using only MAC system.

           

           

          var myDesktop= Folder("~/Desktop");
          var Doc = app.activeDocument;
          var myPath = myDesktop+"/InDesign Document Page Range_Report.txt";
          var myReportFile = new File(myPath);     
          
          Arr=new Array();
          var myReportname="";
          
          var myDocName = Doc.name.split(".")[0];
          var myDocName1=myDocName.split("_")[1];
          var parentFolderName = String(Doc.filePath).split("/").pop();
          var Foldername = parentFolderName.substring(0,7)//Folder first 3 characters triming like US_
          alert(Foldername+"\t"+myDocName1);
          if(myDocName==Foldername){
               //alert ("Yes, your file name and folder name are same")
               }
          else{
               Arr.push(myReportname=parentFolderName+"\t"+myDocName+"\n");
               //alert ("No, your file name and folder name are different");
               }
          
          myReportFile.open ('w');
          if(myReportname.length!=0){
               myReportFile.writeln("==============================================================================================\n                Report on InDesign Document Page Range Mismatched\n==============================================================================================\n");
               myReportFile.writeln("INDESIGN FILE NAME : "+myDocName+".indd");
               myReportFile.writeln("DATE               : " + new Date());
               myReportFile.writeln("\rFolder Name \tInDesign Document Name\n");
               myReportFile.writeln(Arr.join("\r"));
               myReportFile.writeln("\r==============================================================================================\r");
               }
          myReportFile.close();
          
          if(myReportFile.length==0){
               try{myFile.remove();}catch(e){}
               }
          else{
               try{myReportFile.execute();}catch(e){}
               }
          

           

          Please try and let me know.

           

          thx

          csm_phil

          • 2. Re: Help me!!!!!!!!
            Bhatt, Manish Level 1

            Hi,

             

            I have run this script but we have face the some problem on the script like if the file name is correct then message log not shown other wish the file name is not correct then message log shown if problem you can again correct the script and run to batch also please help me.

             

             

            Thank manish

            • 3. Re: Help me!!!!!!!!
              csm_phil Level 4

              Hi Manish,

               

               

              Can you give the example snapshot clear, after that i will change the script as your requirement.

               

              thx

              csm_phil

              • 4. Re: Help me!!!!!!!!
                Bhatt, Manish Level 1

                Can you create a batch script.

                 

                All batch file log only single those file name is incorrect

                 

                not correct file name shown on error log

                • 5. Re: Help me!!!!!!!!
                  csm_phil Level 4

                  Hi Bhatt,

                   

                  I am ask to you can you give the snapshot of the folder structure and InDesign file name both.

                   

                  thx

                  csm_phil

                  • 6. Re: Help me!!!!!!!!
                    Bhatt, Manish Level 1

                    Hi

                     

                    file:///Users/ubhatma/Desktop/Screen%20shot%202011-08-01%20at%203.15.39%20PM.png
                    the correct one is US_108-109 and incorrect is US_106_107, I have only error log on incorrect file not correct file

                    • 7. Re: Help me!!!!!!!!
                      Bhatt, Manish Level 1

                      see screen short

                       

                      Screen shot 2011-08-01 at 3.15.39 PM.png

                      • 8. Re: Help me!!!!!!!!
                        Bhatt, Manish Level 1

                        See a screen short again.

                         

                        Screen shot 2011-08-01 at 4.00.51 PM.png

                        • 9. Re: Help me!!!!!!!!
                          Bhatt, Manish Level 1

                          thanks you!

                           

                          I have also creating run in batch please check

                           

                          var myDesktop= Folder("~/Desktop");

                          var myPath = myDesktop+"/InDesign Document Page Range_Report.txt";

                          var myReportFile = new File(myPath);    

                           

                          Arr=new Array();

                          var myReportname="";

                           

                          try{

                          // Ask for the input and output folder (or hardcode define them if you want)

                          inFolderName= Folder.selectDialog ("Input Folder:");

                          // inFolderName = "/ID Files";

                           

                          if (inFolderName != null )

                          {

                          var idFileFolder = new Folder(inFolderName);

                          // If you need the script to create the folder, do this

                          //var expFileFolder = new Folder(outFolderName);

                          //expFileFolder.create();

                          var dir;

                          dir = idFileFolder.getFiles();

                          //for each sub folder

                          for(i=0;i<=dir.length-1;i++)

                          {

                          var idFileFolder1=new Folder(dir[i]);

                          // get the list of files that are InDesign files

                          var files = idFileFolder1.getFiles("*.indd");

                          for(myCounter = 0; myCounter < files.length; myCounter++)

                          {

                          app.open(File(files[myCounter]), true);

                           

                          var Doc = app.activeDocument;

                           

                           

                           

                          var myDocName = Doc.name.split(".")[0];

                          var myDocName1=myDocName.split("_")[1];

                          var parentFolderName = String(Doc.filePath).split("/").pop();

                          var Foldername = parentFolderName.substring(0,7)//Folder first 3 characters triming like US_

                          //alert(Foldername+"\t"+myDocName1);

                          if(myDocName1==Foldername){

                               //alert ("Yes, your file name and folder name are same")

                               }

                          else{

                               Arr.push(myReportname=parentFolderName+"\t"+myDocName+"\n");

                               //alert ("No, your file name and folder name are different");

                               }

                           

                          app.activeDocument.close();

                          //Note that you could also use:

                          }

                          }

                          }

                          }

                           

                          catch ( err ) {

                          // Silently fail

                          }

                           

                           

                           

                           

                          myReportFile.open ('w');

                          if(myReportname.length!=0){

                               myReportFile.writeln("=================================================================== ===========================\n                Report on InDesign Document Page Range Mismatched\n============================================================================= =================\n");

                               myReportFile.writeln("INDESIGN FILE NAME : "+myDocName+".indd");

                               myReportFile.writeln("DATE               : " + new Date());

                               myReportFile.writeln("\rFolder Name \tInDesign Document Name\n");

                               myReportFile.writeln(Arr.join("\r"));

                               myReportFile.writeln("\r================================================================= =============================\r");

                               }

                          myReportFile.close();

                           

                          if(myReportFile.length==0){

                               try{myFile.remove();}catch(e){}

                               }

                          else{

                               try{myReportFile.execute();}catch(e){}

                               }

                          • 10. Re: Help me!!!!!!!!
                            csm_phil Level 4

                            Hi Bhatt,

                             

                            I have to modifed the JS Code please try, i hope the is the you expect, Please rever for the updates if any.

                             

                            var myDesktop= Folder("~/Desktop");
                            var myPath = myDesktop+"/InDesign Document Page Range_Report.txt";
                            var myReportFile = new File(myPath);    
                            Arr=[];
                            var myReportname="";
                            
                            try{
                                 // Ask for the input and output folder (or hardcode define them if you want)
                                 inFolderName= Folder.selectDialog ("Input Folder:");
                                 // inFolderName = "/ID Files";
                                 if (inFolderName != null ){
                                      var idFileFolder = new Folder(inFolderName);
                                      // If you need the script to create the folder, do this
                                      //var expFileFolder = new Folder(outFolderName);
                                      //expFileFolder.create();
                                      var dir;
                                      var myDocName1;
                                      var myDocNum;
                                      dir = idFileFolder.getFiles();
                                      //for each sub folder
                                      for(i=0;i<=dir.length-1;i++){
                                           var idFileFolder1=new Folder(dir[i]);
                                           // get the list of files that are InDesign files
                                           var files = idFileFolder1.getFiles("*.indd");
                                           for(myCounter = 0; myCounter < files.length; myCounter++){
                                                app.scriptPreferences.userInteractionLevel=UserInteractionLevels.NEVER_INTERACT;
                                                app.open(File(files[myCounter]), true);
                                                var Doc = app.activeDocument;
                                           
                                                var myDocName = Doc.name.split(".")[0];
                                                myDocName1=myDocName.split("_")[1];
                                                alert(myDocName1+"FFFF");
                                                var parentFolderName = String(Doc.filePath).split("/").pop();
                                                var Foldername = parentFolderName.substring(3,10)//Folder first 3 characters triming like US_
                                                myDocNum = myDocName1.substring(0,7);//File name trimming first 3 characters US_ after i get the result (001-002)
                                                alert(Foldername +"\t"+myDocNum);                    
                            
                                                if(myDocNum == Foldername){
                                                     alert ("Yes, your file name and folder name are same")
                                                     }
                                                else{
                                                     Arr.push(parentFolderName+"\t"+myDocName+"\n");
                                                     alert ("No, your file name and folder name are different");
                                                     }
                                                app.activeDocument.close();
                                                app.scriptPreferences.userInteractionLevel=UserInteractionLevels.INTERACT_WITH_ALL;
                                                //Note that you could also use:
                                                }
                                           }
                                      }
                                 }
                            catch (e){
                                 // Silently fail
                                 }
                            
                            
                            myReportFile.open ('w');
                            if(Arr.length!=0){
                                 myReportFile.writeln("=============================================== ===============================================\n                Report on InDesign Document Page Range Mismatched\n========================================================= =====================================\n");
                                 myReportFile.writeln("INDESIGN FILE NAME : "+myDocName+".indd");
                                 myReportFile.writeln("DATE               : " + new Date());
                                 myReportFile.writeln("\rFolder Name \tInDesign Document Name\n");
                                 myReportFile.writeln(Arr.join("\r"));
                                 myReportFile.writeln("\r============================================= =================================================\r");
                                 }
                            myReportFile.close();
                            
                            if(myReportFile.length==0){
                                 try{myFile.remove();}catch(e){}
                                 }
                            else{
                                 try{myReportFile.execute();}catch(e){}
                                 }
                            

                             

                            thx

                            csm_phil

                            • 11. Re: Help me!!!!!!!!
                              Bhatt, Manish Level 1

                              Thank dear

                              • 12. Re: Help me!!!!!!!!
                                csm_phil Level 4

                                Hi Bhatt,

                                 

                                Please select the help full answer or correct answer because the question is still open no one answer so lot of people go and read your thread so please update the status at every time.

                                 

                                thx

                                csm_phil