is now part of CreativePro.com!

ChainGREP: A Script that Gives You GREP Super Powers

26 1

In my experience, there are there are two keys to achieving amazing feats of efficiency and productivity in InDesign: sugar and caffeine scripting and GREP. GREP gives you amazing text processing and formatting power. Scripting allows you to handle a vast amount of work in the blink of an eye. So imagine what you could achieve by creating your own custom scripts that execute chains of GREP queries on your InDesign documents, effectively combining the powers of scripting and GREP. This could be life-changing stuff.

What’s that you say? Sounds great but you don’t know how to script? And you can only handle relatively simple GREP queries? Well fear not, you are the perfect person who should check out a clever solution by Gregor Fellenz. It’s a free script called ChainGREP, and when you run it, you get a dialog box showing all the GREP queries you have saved in InDesign.

You can then select a sequence of those queries

ChainGREP script dialog

and save that sequence in a new script.

More after the jump! Continue reading below
Free and Premium members see fewer ads! Sign up and log-in today.

ChainGREP script result

Then just double-click the new script to run it, and sit back and enjoy the show.

This is so cool because a) you can create incredibly useful scripts without knowing how to script at all, and b) for most of us mere mortals, it’s a lot easier to accomplish tricky GREP tasks with several simple queries, instead of one complex query. Simple queries are just easier to grok, write, and troubleshoot. And now with the help of ChainGREP you can run any number of queries with one double-click.

Even cooler: the queries are saved in the new script you create, so it’s totally independent and portable. You can put it on another machine where those GREP queries don’t exist and it will work just fine.

To find out more about the script and download it, check out this post at Tim Gouder’s InDesign blog. Note that the post is in German, but your browser’s translation will probably be all you need to figure things out (and the script comes in an English version).

Thanks Gregor and Tim!

Editor in Chief of CreativePro and InDesign Magazine. Instructor at LinkedIn Learning with courses on InDesign, Illustrator, GIMP, Inkscape, and Affinity Publisher.
  • I made a youtube screencast about the script https://www.youtube.com/watch?v=P8YIjGP2O04&t=4s – but also geramn ;-(

    • Cherelyn says:

      Thank you so much for sharing this. I have built a load of find/change GREP queries and have just been running them one after another. I’m so excited to try it.

  • Aaron Gray says:

    Wow, this sounds like just the kind of thing I’ve been dreaming of! I’m really excited to try this out. I have a zillion saved GREP searches that I’ve created, and I use the Multi-Find/Change plug-in to execute them in batches, but I’m really bad at writing Javascript. This is just what I’ve often wished I had, to bridge the gap and package several GREP searches into one script that I can easily share with other designers that I work with. Thank you!

  • Anne-Marie Concepcion says:

    Aaron I’d love to see the script you end up with!

  • Molly Zisk says:

    I create a quarterly magazine and can’t wait to try this and eliminate several tedious tasks.

  • Tim Gouder says:

    Hello Mike,
    a million thanks for mention my blog and Gregors guest article (even it’s in German ;) !
    We are very honoured. Hope everyone have fun with the script.
    Keep up the good work here at InDesignSecrets.com
    Regards,
    Tim

  • Masood Ahmad says:

    My initial thought was that this script will bring an end to the Find Change by List JavaScript, but then I realized that it will only work if you have the necessary GREP/FindChange user queries saved in your system. Which means that to use this script on another machine you have to share your queries too. Unlike Find Change by List, all the information is stored within the script (in a text file) and you do not have to worry about the user queries.

    Is it possible that ChainGREP script can store all the queries to a text file and later use it for Find/Change. Because creating a FindChangeList.txt file is sometimes very confusing.

    I’ll check if I can edit the script to read the Find/Change Queries from a custom folder.

    My second thought, the script is a good and FREE replica for Multi-Find-Change script. Thanks for sharing.

    • No need to share your queries, they are converted to javascript. The resulting script is totally independent.

      This also means: If you update your query, you need to recreate your find change script.

      • Masood Ahmad says:

        That’s wonderful. So my initial thought was correct. It has bring an end to the Find/Change by List script. I didn’t opened the resulting JavaScript and thought that the Chain Script will work with the queries only.

        Once again million thanks to the creator.

  • Chad Beery says:

    Thank you for this free script, it looks very useful!

    I did run into one issue. I have a find/change that applies an italic character style to anything that is formatted as italic. When I run the script it seems to ignore that step.
    If I run it manually in the same document it works fine.

    I have around 15 find/changes in my list and all the others seem to work including several that apply paragraph styles.

  • Chad Beery says:

    I was able to modify the final script so that it now applies character styles.
    I could not figure out how to fix the original starter script.

  • Frans van der Geest says:

    Don’t forget the excelent, but not free, MltiFindChange of course. This allows for Text and GREP to be combined, make sets etc. Truly a geat addition to InDesign:
    https://www.automatication.com/index.php?id=24

  • me meeee Mee ee says:

    I rather need something where i can add in chain TEXT find/change rules (inlcuding styles) not only GREP. This is done by default findchangebylist.jsx but it load only one file – so its also useless.

    • Simply convert your TEXT Find/Change to GREPs they are equivalent if you keep an eye on special characters like: \ . * + ? ( ) {} [ ^ $ | ~
      And a GREP Query includes style mappings and even all other options you can tick.

      • me meeee Mee ee says:

        “Simply convert your TEXT Find/Change to GREPs”

        How? GREP is not able to translate inner Indesign styles into code. Even so what plugin could understand and run such format.

      • David Blatner David Blatner says:

        The best solution is probably MultiFindChange from Automatication, which was mentioned above

      • findchangebylist.jsx says:

        Thx David but this is not free. Is it really so difficult to do script in which you can change on-fly file for findchangebylist.jsx ? Now i have about 10 files and every time i must change file name to load it by script.

        I cant afford to buy every plugin to In, PS etc.. that’s why i was interested in this post (free script) but it doesnt do what i want to.

        Suggestion for you David… article about what plugin is worth to buy for In for 100$ or 50$

      • David Blatner David Blatner says:

        It is true that MultiFindChange is about $50. Depending on your job (your hourly rate), this might be between 2 hours of your time and 15 minutes of your time. But if it is not worth $50 of your time, then you probably don’t need a script.

        There are many worthwhile plug-ins for $50 or $100 — we talk a lot about them in InDesign Magazine. Which is also about $50. :-) We all have to try to make a living. Free scripts and free software and free information is great, except that no one can support it for very long.

      • me meeee Mee ee says:

        “this might be between 2 hours of your time and 15 minutes of your time.”

        David you forget that rich America/West istn the whole world. In many eastern countries 50$ is max (average) what they can earn for two days.

  • Roger Morgan says:

    I’m sure could come up with an InDesign version of this:

    https://xkcd.com/208/

  • Randy Miller says:

    These GREP discussions have really inspired me. I can’t program scripts, etc, but i sure can copy and play with the scripts that show up here. This ChainGREP is a great way to clean up copy in one fell swoop. I’ve even placed these in Indesign menus (based on other scripts that slip into menus). I have a Clean Up menu that cleans all aspects, or just tabs, spaces, returns individually as menu choices.

  • Bruce Johnson says:

    Great script, but is there something like this that can also handle text and object queries? I would like to have a .jsx like what chaingrep can generate, so MFC wouldn’t be an option.

  • >