3 Replies Latest reply on Dec 10, 2014 6:24 AM by Peter Spier

    FindChangeList

    Kirikokos

      How does the script FindChangeByList know which area it should apply the find/change commands in the document??

       

      Example:

       

      I have a tabel with 4 columns - The first 2 columns need a GREP style and third column need a different GREP style -

      But how can the script know that? Is this at all possible with the FindChangeByList script?

      -----

      //FindChangeList.txt

      //A support file for the InDesign CS4 JavaScript FindChangeByList.jsx

      //

      //This data file is tab-delimited, with carriage returns separating records.

      //

      //The format of each record in the file is:

      //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description

      //

      //Where:

      //<tab> is a tab character

      //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).

      //findProperties is a properties record (as text) of the find preferences.

      //changeProperties is a properties record (as text) of the change preferences.

      //findChangeOptions is a properties record (as text) of the find/change options.

      //description is a description of the find/change operation

      //

      //Very simple example:

      //text    {findWhat:"--"}    {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double dashes and replace with an em dash.

      //

      //More complex example:

      //text    {findWhat:"^9^9.^9^9"}    {appliedCharacterStyle:"price"}    {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}    Find $10.00 to $99.99 and apply the character style "price".

      //

      //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.

      //

      //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"

      //as shown in the example below:

      //

      //{findWhat:"\\s+"}

      //

      grep    {findWhat:"  +"}    {changeTo:" "}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double spaces and replace with single spaces.

      grep    {findWhat:"\r "}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a space And replace with single returns.

      grep    {findWhat:" \r"}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a space and replace with single returns.

      grep    {findWhat:"\t\t+"}    {changeTo:"\t"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double tab characters and replace with single tab characters.

      grep    {findWhat:"\r\t"}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a tab character and replace with single returns.

      grep    {findWhat:"\t\r"}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all returns followed by a tab character and replace with single returns.

      grep    {findWhat:"\r\r+"}    {changeTo:"\r"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all double returns and replace with single returns.

      text    {findWhat:" - "}    {changeTo:"^="}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all space-dash-space and replace with an en dash.

      text    {findWhat:"--"}    {changeTo:"^_"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}    Find all dash-dash and replace with an em dash.

        • 1. Re: FindChangeList
          Peter Spier Most Valuable Participant (Moderator)

          The only way Find/Change (including Find/Change by List) can differentiate between text that should be changed and text that should not is if there is something different about the text, typically an applied style if the string would find both text that should change and text that should not.

          • 2. Re: FindChangeList
            Kirikokos Level 1

            example.jpgOkay... So I should apply an style before I run the script which have all the different information...

            Could you maybe look at the picture and think of and solution?

            • 3. Re: FindChangeList
              Peter Spier Most Valuable Participant (Moderator)

              If all the numbers are either 9-digits or 2-digits you can use that to identify the columns and make the correct changes.

               

              For the first column, ^\d{9}$ and change to $0,

               

              For the third column ^\d{2}$ and change to $0 PCS.

               

              these expressions require that the paragraph contain only a number of the exact length, and no other characters of any sort. You can modify them to use a minimum/maximum digit count, as long as the ranges don't overlap.