Macro/Script for multiple text find-change queries?

Learn / Forums / General InDesign Topics / Macro/Script for multiple text find-change queries?

Viewing 14 reply threads
  • Author
    Posts
    • #54945
      Eric Chapman
      Member

      I regularly import text that has repetitive static portions (like chapter titles/subheadings) in a foreign language, though the main text is okay. I'd like to create some kind of way to automate the replacement of over 60 different foreign words that recur regularly in different texts imported to different ID files, but I don't want to have to run 60 different queries. Is there a way to “link” queries together so ID would run all 60 one after another (say, a “query bundle”)? Or create a macro or script that would do this? An example would be importing into several different InDesign files calendar data with, say, French month names, but all the other data was already in English. If I did lots of calendars, it'd be worth it to have an automated way to change all French month names to English rather than doing it manually or running 12 queries. This is simple in, say, MS Word, where you just record a macro as you're doing it the first time, and then it's available permanently. I've looked into GREP, etc., but it seems ID's Find-Change function is limited to one string being replaced by one string only, whereas I want to replace “FRstring1″ with “ENstring1″, then “FRstring2″ with “ENstring2″, etc.

    • #54946
      Colin Flashman
      Participant

      you can, using findchangebylist.jsx, and the script is shipped with adobe indesign. manipulating the queries is done by navigating to the text file where the script calls its queries from, normally findchangelist.txt. there is the ability to generate hundreds of different lists and when running findchangebylist.jsx, navigate to the text file which contains the find/changes you want to use.

      this bit is fairly cody, not really user friendly for non-coders. to make things easier, there is a script called RecordFindChange_CS3.jsx which can be found at https://indesign.hilfdirselbst……s3jsx.html (may want to use a google translator if you don't speak german)

      My workflow is like this: I make a copy of the findchangelist.txt and name it appropriately based on what i'm changing (i.e. particularcustomerchanges.txt). In Indesign, i make a find/change query and test it on the file i want to change, and when i'm satisfied that the change works (particularly for GREP expressions) i use the RecordFindChange_CS3.jsx script and copy the text it generates into the text file i had.

      i hope that makes sense… i'm so used to doing it i've probably missed vital steps :D

    • #54947
      Eric Chapman
      Member

      Wow! You've encouraged me that it's possible!

      However, I'm afraid it's going to take a while for me to catch on to this. I've never used scripts at all (in OS X or in InDesign), so I need to learn some things. I subscribe to lynda.com, so maybe I could watch some video on how to do scripts, etc. there. However, I don't see anything on CS4 and scripting there.

      One thing that will make my use slightly more complicated is that it'd be best to check the text following the to-be-changed-text and see if it is followed by any number of digits (up to 3) , a colon and any number of digits (up to 3). If so, the change should be made; if not, it should not be made. I realize all that is possible, and now I see how ID intends for us to do it. But this seems rather daunting to me. I don't even know how to run the scripts :) I'd like to see a sample file of say all the English month names being converted to another language via script if and only if they are followed by a space and up to 3 digits and then a colon and up to 3 digits again. So “January 123:321” would be changed to “Januar 123:321”, but “January” alone would not be. Then I might be able to imitate what I need and use it.

      Any idea where best on the web to learn the scripting I need? (I have lynda.com's ID Beyond the Basics DVD (by David Blatner), but it doesn't seem to have any scripting chapters in it.

      Sincere thanks!

    • #54948
      Colin Flashman
      Participant

      there's a forum for scripts which is really helpful: https://forums.adobe.com/commun….._scripting

      in terms of learning, there is the official adobe page: https://www.adobe.com/products/…..scripting/

      otherwise o'reilly has lots of books on the subject.

      i'm all new to it but i know that word-like macros can be made and i've used them to output paying jobs, so its possible. as to how complicated they are and what solutions are required are case by case. i'd pose it to the scripting forum in indesign, or even the scripting forum within indesignsecrets of course :D

      colly

    • #54949
      Eric Chapman
      Member

      Thank you! I'll do some studying! :)

    • #54959

      “January 123:321″ would be changed to “Januar 123:321″, but “January” alone would not be.

      That's a good candidate for search-and-replace with GREP.

      Try this, with plain InDesign, using the GREP Search and Replace dialog. Search for

      <January(?= ddd:ddd)

      and replace with

      Januar

      (Mind not to forget the space immediately following the equals.) If you press the “Find next” button, you will see it miraculously skips all Januaries that stand on their own …

      The (?= ..) stuff is called a lookahead. It means “January” will only be found when it is followed by a space, three digits, a colon, and then three more digits. However, this suffix will not be “marked” by the Find function — only the plain text “January” will be selected! And only this selected part will be replaced with whatever you put into the “Replace” field.

      You can put this straight into the FindChangeBy script data file for every month to replace (or, better, use the Record script because the syntax of that data file can be a bit daunting).

    • #54960

      Jongware said:

      “January 123:321″ would be changed to “Januar 123:321″, but “January” alone would not be.

      That's a good candidate for search-and-replace with GREP.

      Try this, with plain InDesign, using the GREP Search and Replace dialog. Search for

      <January(?= ddd:ddd)

      and replace with

      Januar

      (Mind not to forget the space immediately following the equals.) If you press the “Find next” button, you will see it miraculously skips all Januaries that stand on their own …

      The (?= ..) stuff is called a lookahead. It means “January” will only be found when it is followed by a space, three digits, a colon, and then three more digits. However, this suffix will not be “marked” by the Find function — only the plain text “January” will be selected! And only this selected part will be replaced with whatever you put into the “Replace” field.

      You can put this straight into the FindChangeBy script data file for every month to replace (or, better, use the Record script because the syntax of that data file can be a bit daunting).


    • #54982
      Eric Chapman
      Member

      Thank you very much! I'll work on it and see if I can figure out how to do it.

      Kind Regards,

      Eric

    • #54986
      Eric Chapman
      Member

      Here's what I did since the string does not always include 3 digits before the colon and 3 after it, and this worked fine to find the proper ones and change them (one at a time).

      In GREP “Find what:” <January(?= d+?:+?)

      In GREP “Change to:” Januar

      Now I'm trying to figure out how to record about 60 of these in one place. I have installed the

      RecordFindChange_CS3_Kas.jsx

      referred to here (https://creativepro.com/fin&#8230;..odness.php) and found here (https://www.kasyan.ho.com.ua/sc&#8230;..ories.html). I can see how it records the current parameters in the Find-Change dialog box to a text document called “findChangeStrings.txt”, but I haven't gotten the InDesign Script (that comes with ID CS4) called

      FindChangeByList.jsx

      to be able use what is saved in that file. I would assume the new text file with the intended Find-Change items saved by the RecordFindChange script should be saved maybe in the “Find Change Support” folder or where the original FindChangeList.txt file was. But I tried that and tried to run the FindChangeByList.jsx script, and nothing happened.

      I also noted that the new text file still has some other stuff at the top for a text query. Maybe that must be deleted first? I tried that, but it also didn't work. Can there only be one FindChangeList.txt file? Does it have to have that name to run in the script? How should I save different txt files for this script and where should they be stored? How are they accessed?

    • #54987
      Eric Chapman
      Member

      Oops. Should have been a backslash before the less than symbol so it would be: <January(?= d+?:+?)

    • #54988
      Eric Chapman
      Member

      Double oops. Should have been:

      <January(?= d+?:d+?)

    • #54989
      Eric Chapman
      Member

      Well, some of it's me. I left out a “d”, etc. But the forum won't let me type in a backslash – it deletes it. How do I?

    • #55009
      Boddhi
      Participant

      For a multiple request with grep, you should look here

      https://www.kahrel.plus.com/ind&#8230;..eries.html

      good luck

    • #103323
      Civi Bernath
      Participant

      I see this is an old conversation, so I hope I can add this.
      I have a catalog of about 5,000 items and now I need to delete about 500 of them. I have a list of the item numbers
      example:
      S123
      S124
      S126
      S138
      etc.

      I want to replace all these item numbers with the word “delete” and then I can find them and remove the whole entry (image, price, etc.)
      I do use the included scripts, but when I double click the “findchangebylist” nothing happens.

      Any ideas?

    • #103324

      Hi,

      Thanks to create a new topic and be more explicite! Thanks!

      Best,
      Michel, from FRIdNGE
      [email protected]

Viewing 14 reply threads
  • You must be logged in to reply to this topic.
>