Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Recurrent Open And Save Indd Files In a Whole File Tree using JS

Return to Member Forum

  • Author
    Posts
    • #80730
      Marcin Ploch
      Member

      Hello,
      I’m very beginner of Indesign java cripting.
      I need an universal java script which can:
      1. open ALL indd files in a tree of files recurrently through the end of a tree (no matter how many levels are in the tree)
      2. do some code (e.g. delete all the frames from the pasterboard)
      3. seve and close the indd document

      I will be very grateful for any help :-)

      Best regards
      Marcin

    • #80757
      Mike Dean
      Member

      I have a similar script that I used to use years ago. It will loop through all the files in a single folder, run code on each file, then save and close (your code would go after the ////Script goes here line).

      It only runs on a single folder though, it doesn’t go through subfolders. Recursion hurts my brain so I probably can’t help you there, but maybe this is at least a start. Also, it saves over all the files, so you’ll probably want to create backups before running this in case anything goes wrong.

      Here’s the code for the script:

      //This script will execute a script on all INDD files in selected folder

      var myFolder = Folder.selectDialog(“Choose an Folder”)
      var myFiles = myFolder.getFiles( “*.indd” );

      //disables warnings (missing fonts, etc.)
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

      //If you’re placing a for loop within this loop, make sure the variables are different
      for( var i = 0; i < myFiles.length; i++ ){
      if (myFiles[i].name.slice(-5) == “.indd”){
      myCurrentFile = app.open(myFiles[i])
      }
      /////////////////////////

      ////Script goes here

      myCurrentFile.close (SaveOptions.YES)

      ////////////////////////
      }

      //re-enable warnings
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll

    • #80782
      Keith Gilbert
      Participant

      Check out Peter Kahrel’s “Batch-process” script here: https://www.kahrel.plus.com/indesign/batch_convert.html

      It will do what you need. It will process subfolders, and will allow you to run a second script on the files it processes.

    • #80891
      Marcin Ploch
      Member

      Many thanks Keith and Mike :-)
      You answers helped me a lot !!!

      Best regards
      Marcin

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
Forum Ads