1 Reply Latest reply on Sep 16, 2013 12:02 AM by Green4ever

    Need help on deleting after exporting to IDML

    indegn5 Level 1

      Hi Forum,

       

      I have a script to export all the "indesign files" found inside the folder... and then remove all the indesign files...

       

      Instead, Can i have a help to delete....

       

      the indesign file after exporting to IDML and then

       

      continue opening the next indesign file, exporting to IDML and deleting it...

       

      then continue file3....

       

       

      The below is the script open indesign files and export to idml and then remove all the files inside the folder Desktop/GENERAL_CS6-IDML/IN_CS6

       

      var mySourceFolder = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");

      var myOutFolder = Folder("Desktop/Completed");

       

      //var Indd_files = get_Files(mySourceFolder,[], ".indd");

      var Indd_files = mySourceFolder.getFiles (/\.indd|\.INDD/i);

      //var Indd_files = get_Files(mySourceFolder,[], ".indd");

       

      if(Indd_files.length>0)

      {

          for(var w=0;w<Indd_files.length;w++)

          {

              try{

                   app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

                  myDoc = app.open(File(Indd_files[w]));

                   app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

                   var myDocNam = stripExt((Indd_files[w].name).replace(/%20/g," "))+"idml";

                   myDoc.exportFile(ExportFormat.INDESIGN_MARKUP, (File(myOutFolder+"/"+myDocNam)));           

      //          myDoc.save(File(myOutFolder+"/"+myDocNam));

                  app.activeDocument.close(SaveOptions.no);

              }catch(E){}

          }

      }

       

       

      try {

      var copyFolder1 = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");

      var myFiles2 = copyFolder1.getFiles(/\.indd|\.INDD/i);

       

      for ( i = myFiles2.length-1; i >= 0 ; i-- ){

      myFiles2[i].remove();

      }

      } catch (e) {}

       

       

      Many thanks for the support..

        • 1. Re: Need help on deleting after exporting to IDML
          Green4ever Level 3

          I hope this is what you expected.

           

          You can try the following code:

           

           

          var mySourceFolder = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");
          var myOutFolder = Folder("Desktop/Completed");
          //var Indd_files = get_Files(mySourceFolder,[], ".indd");
          var Indd_files = mySourceFolder.getFiles (/\.indd|\.INDD/i);
          //var Indd_files = get_Files(mySourceFolder,[], ".indd");
          if(Indd_files.length>0)
          {
              for(var w=0;w<Indd_files.length;w++)
              {
                  try{
                       app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                       var myFile = File(Indd_files[w]);
                      myDoc = app.open(myFile);
                       app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                       var myDocNam = stripExt((Indd_files[w].name).replace(/%20/g," "))+"idml";
                       myDoc.exportFile(ExportFormat.INDESIGN_MARKUP, (File(myOutFolder+"/"+myDocNam)));           
                      app.activeDocument.close(SaveOptions.no);
                      myFile.remove();
                  }catch(E){}
              }
          }
          

           

          ---------------

          Green4ever