21 Replies Latest reply on Jul 15, 2014 4:56 AM by fabianmoronzirfas

    batch-find-and-replace.jsx

    fabianmoronzirfas Level 1

      Hi there, I wrote a batch-processing script for find change queries and thought I share it with you. You can get it over here 

      You can process GREP, TEXT, GLYPH and OBJECT searches. 

      Purpouse

      While creating books in InDesign with several documents we always come across some find change queries that need to be used again, and again, and again. To make this process easier you can just grab their names and put them into a list. The script will than try to process all your queries in one click. 

      prerequisites

      1. make sure you have a toml file.
      2. make sure the toml file is next to the script.
      3. make sure the toml file has the right formatting (see below in section TOML)
      4. if you want the script to autoexecute (without toml file selection), make sure the .toml file has the right name: "batch-find-and-replace.toml"
      5. make sure your fcqueries work right

      Usage

      • Place the script and the toml file into your Scripts Panel Folder 
      • define some find and change queries and save them via the InDesign dialogue.
      • get the xml file names and add them to the "batch-find-and-replace.toml" file in the right spot. text search goes into text.files = [], grep search goes into grep.files = [] and so on. Make shure to remove the .xml from the filename. You can find these files on:
        • Mac OS Users[username]\Library\Preferences\Adobe InDesign[Version][Language]\Find-Change Queries[query type] 
        • Windows XP Documents and Settings[username]\Application Data\Adobe\InDesign[Version][Language]\Find-Change Queries[query type] 
        • Windows Vista and Windows 7 Users[username]\AppData\Roaming\Adobe\InDesign[Version][Language]\Find-Change Queries[query type] 
      • the .toml file should be located next to the script file and have the  appropriate name (batch-find-and-replace.toml). If so the script wont ask for the toml file and process the data right away. If not the script will ask you to select the .toml file.
      • Thats it. Watch the magick happen.

      TOML

      Tom's Obvious, Minimal Language is a simple markup language that makes settings human readable. It is still in development and may change a lot. But still. It is a pretty easy language and can be learned by anyone.
      The basic toml filer looks like this: 

      # these are the basic settings
      # the MUST be there
      do_text = true
      do_grep = true
      do_glyph = true
      do_object = false
      # now the file names
      # they have to be in one line
      # the toml specs say you can break lines in arrays
      # but the toml.js does not allow that at the moment
      [text]
      files = ["my_first_text_find_and_change","another one"]
      [grep]
      files = ["somegrepsearch", "find tabs", "something else"]
      [glyph]
      files = []
      [objects]
      files = []
      

      MUST HAVE Settings

      With the do_text, do_object, do_grep and do_glyph you can define if the script should do the corresponding find and replace. Set them to true or false.

      CAN HAVE Settings


      In the [text],[grep],[glyph] and [objects] areas you can define the filenames that should be processed. Make sure the filenames are written right. If there is a file mentioned that does not exist the script will throw an error. It will try to process all the .xml files it can find.
      !IMPORTANT! you MUST remove the .xml from the filename in the list as shown above.

       

      The Script is here --> https://raw.github.com/...find-and-replace.jsx

      The basic .toml file here --> https://raw.github.com/...ind-and-replace.toml

      The Readme here --> https://github.com/...lob/master/README.md

      And the whole package here --> https://github.com/...e/archive/master.zip