Text or GREP find/change method to assign tags

Hi all
I could use a text or GREP find/change method to  assign tags to paragraph styles (for use in FindChangeByList), would anyone be able to help please?
Steve

Hi Peter
I produce a quarterly magazine for which text is supplied in Word format.
I currently run the 'FindChangeByList' script to format body text, headings, bulleted and numbered lists, web and email address text styling and to remove/correct all extraneous characters etc.
Once the job is printed I need to produce a tagged 'accessible' readable (eg: read out loud function in Acrobat) pdf from the file, for text to speech readers.
I am currently using the map tags to styles function, which allows me to assign tags which in turn gives me control of the 'text reading' order.
What I'd like to be able to do is automatically apply the Tags to syles while processing the 'FindChangeByList' script.
Steve

Similar Messages

  • Finished script: Use grep find/change to fill in a supplied table of contents

    This script is now complete, and has been the subject of most of my previous posts. Just in case anyone wanted to know what the finished script ended as, here it is.
    Thanks so much to all. A lot of really helpful folks on this board are very responsible for the success of this task. This script is to be one of hopefully many in the creation of our records. But it's a huge leap forward. Thanks again to everyone that helped.
    Cheers,
    ~Nate
    Task:
    Automatically find town names in listings, and fill in table of contents template on page 2 accordingly.
    Example of page 2 toc, initially:
    Example of a page of content. The town names are what need to be referenced on the TOC:
    Example of page 2 toc once script is finished:
    Because of the need to include the transaction dates on the TOC (comes as a provided, tagged-text file), a simple Indesign-generated TOC can't be used alone.
    This script uses an Indesign-generated TOC that's on a master page called "T-tocGen" ... It then uses grep search and replaces to grab the needed information, and insert it into the page 2 TOC.
    The script will update a generated TOC and then search for an instance of a page number, and town name. The generated toc lists all included towns in the following format:
    (line start)## tab townName(line end)
    In Grep, this would be (please note, extra \ for \d and \t ... javascript needs that for some reason):
    ^\\d+\\t(.*)$
    After the script gets the info it needs from a found instance of the above, it replaces that line with "---", to prevent that line from being picked up once again.
    The script with then place the needed page number in it's rightful place on page 2, replacing the XX.
    A while loop is used to repeat the above process until there are no longer any instances of "^\\d+\\t(.*)$" present.
    Not every town runs every issue, so once the script is done, it removes all remaining instance of "XX" on the page 2 TOC.
    FINAL CODE:
    TOC replace
    This script will use grep find/change methods to apply page numbers in
    tocGen to the XX's on page2TOC.
    // define the text frame of generated TOC
        var tocGenFrame  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
    // udpate generated TOC ... store contents in tocGenStuff
        var tocGenStuff = updateTOCGen();
    // set variable for while loop
    var okGo = "1";
    // while okGo isn't 0
    while(okGo.length!=0)
    // get town info from tocGen
    getCurrentTown();
    // replace XX's with tocGen info
    replaceTown();
    // grep find ... any remaining towns with page numbers in tocGen?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // set current value of okGo ... with any instances of above grep find in tocGen
    okGo = tocGenFrame.findGrep();   
    // grep find/change all leftover XXs in page2TOC
    app.findGrepPreferences = app.changeGrepPreferences = null;       
    app.findGrepPreferences.findWhat = "^XX\\t";
    app.changeGrepPreferences.changeTo = "\\t";
    app.activeDocument.changeGrep();  
    // clear grep prefs
    app.findGrepPreferences = app.changeGrepPreferences = null;
    //  functions                  //
    function getCurrentTown()
    // grep options   
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // grep find:  startLine anyDigits tab anyCharacters endLine
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // get grep find results      
    currentGen = tocGenFrame.findGrep();  
    // store grep results content into currentLine
    currentLine = currentGen[0].contents;
    // match to get array of grep found items
    currentMatch = currentGen[0].contents.match("^\\d+\\t(.*)$");
    // second found item is town name, store as currentTown
    currentTown = currentMatch[1];
    // change current line to --- now that data has been grabbed
    // this is because loop will continue as long as the above grep find yields a result
           app.findGrepPreferences.findWhat = "^\\d+\\t"+currentTown+"$";
                  app.changeGrepPreferences.changeTo = "---";
                tocGenFrame.changeGrep(); 
    function replaceTown()
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // find: XX currentTown .... replace with: currentLine
        app.findGrepPreferences = app.changeGrepPreferences = null;
        app.findGrepPreferences.findWhat = "^XX\\t"+currentTown+" \\(";
        app.changeGrepPreferences.changeTo = currentLine+" \(";
    app.activeDocument.changeGrep();   
    function updateTOCGen()
    //set vars ... toc text frame, toc master pag
        var tocGen  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
        var tocGenPage  = document.masterSpreads.item("T-tocGen").pages.item(0);
    //SELECT the text frame generatedTOC on the master TOC
        tocGen.select();
    //Update Table of Contents by script menu action:
        app.scriptMenuActions.itemByID(71442).invoke();
    //Deselect selection of text frame holding your TOC:
        app.select(null);
    //store contents of toc text frame in variable
        var tocGenText = tocGen.contents;
    //return contents of tocGen
        return tocGenText;

    Thanks for the reply.
    You are correct but the problem is there are three rows, One row is 100% black, the second is 60% black and the third is 40% black. I want to change the black to blue, the 60% black to an orange and the 40% black to a light shaded blue. In the find/change option you can select the tint you want to find and replace but yea.. does work on table cells.. oddly enough.

  • GREP 'find/change' by list script: find a text string containing different para styles

    Hi
    I'm don't write scripts but do 'enjoy' copying, pasting and changing existing code/txt files.
    I have built a GREP find/change .txt that performs a large number of text edits/changes.
    But I'm left with an issue where I have paragraphs of text (styled earlier in the .txt file) that I'm unable to identify using GREP the usual way. I need to identify text in a particular paragraph style, followed by text in another paragraph style.
    Is it possible with GREP to create a search string to find: text styled with one paragraph style, ending with a paragraph return, and to include in that selection the following paragraph/s styled with another paragraph style?
    MTIA Steve

    seb400 napisał(-a):
    What do you mean by I would mark "changing" in "copying, pasting and changing"?
    Hi Steve,
    I mean I can see a way by modifying some existing code with "find...change" job
    1. set criteria to findGrep
    2. store findGrep() in an array
    3. check each found object if next paragraph matches some new criteria
    4. run changeGrep() if true
    Jarek

  • GREP find/change problem

    Hi, am trying to execute InDesign's default find/change AppleScript script to fix many formatting issues in a large document. One of them is occurences of a two-digit dollar figure followed by a comma (eg. "$10,") that needs to be changed to have no comma.
    Using GREP I can pick it up by finding "\$\d\d," but when I replace it with "\$\d\d" I get the actual string "\$\d\d". IE. "$10," becomes "\$\d\d" rather than "$10". Am I misundersting how the 'change' part of GREP works? Can any one advise?
    FYI the line in the find/change support .txt doc is:
    grep
    {find what:"\\$\\d\\d,"}
    {change to:"\\$\\d\\d"}
    {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}
    Remove commas after prices.
    ...which includes extra backslashes to escape the backslashes that are part of the GREP expression.
    Any help much appreciated!
    Thanks.

    No, unfortunately lookbehinds don't work with variable-length strings. That's the case with all GREP implemantations, not just InDesign's. You can sort of get around it by using or-constructs, but they soon become unmanageable. Here's an example (split and indented just for clarity, you would need to write all this on one line):
         (?<=\$\d)
         |
         (?<=\$\d\d)
         |
         (?<=\$\d\d\d)
    This one says "if a comma is preceded by $ and a digit OR by $ and two digits OR by $ and three digits, then . . ." As you understand, if you need to allow up to six or seven digits, possibly thousand separators too, then lookbehinds become unpracticable.
    >I'm really struggling to get to grips with how GREP statements work.
    Try this: http://oreilly.com/catalog/9780596156008/
    Peter

  • InDesign Scripting or GREP Find/Change?

    Can anyone help me with a script or GREP idea for finding, cutting and pasting the phone numbers at the end of these paragraphs? The first one is what I have and the second is where I would like to get. There are hundreds of these in 4 restaurant directories that I am designing.
    Woodlands (ve) Indian. Weekend buffet. 4078 Jermantown Road. (703) 385-1996. M–F 11:30am–10pm, Sa 11:30am–10pm, Su 11:30 am–9:30pm.
    Woodlands (ve) Indian. Weekend buffet. 4078 Jermantown Road. M–F 11:30am–10pm, Sa 11:30am–10pm, Su 11:30 am–9:30pm. (703) 385-1996.

    You don't need to ask the same question twice. Lets keep all the discussion inthe original topic please,
    http://forums.adobe.com/message/3856456#3856456
    If you are not able to make the anser I provide there work, please provide some details about what is not working, and some before and after screen shots.

  • GREP query for find/change operation

    Hi everyone,
    In the following line, there's a comma after the first name. This type of formatting is repeated hundreds of times on a number of pages so I need to use a GREP find/change query to remove the comma after the first name and replace it with a space.
    Firstname,Lastname,State
    I wondered if something could tell me what the GREP code would be?
    Appreciate any assistance.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    ..  it's also doing it for the second comma
    That's impossible. You must have entered something else than Scott's code.

  • Applescript find/change problem

    I have some text which needs to be styled in InDesign CS4 which has a bunch of extraneous tags ( eg. <b>, <i>, etc.). I have customised the FindChangeList.txt file that supports the FindChangeByList.applescript file to do things like:
    {find what:"<i>"}
    {change to:"^S"}
    which can then be picked up by a nested style. All good so far.
    Problem: the applescript will just not 'see' the strings <b> or </b> in FindChangeList.txt. It treats them like they aren't there. I can do it using the find/replace within InDesign, it works fine there, but my problem is that I have hundreds of pieces of copy to import and I'd like to automate as much as possible. Using GREP has the same effect, ie. works in find/replace within InDesign, but not with applescript.
    Any help would be greatly appreciated as this is really killing me at the moment. Thanks!
    Content of FindChangeList.txt follows. The command in the final line works, the command in the second-last line doesn't.
    (FYI the second line of code contains 'InDesign CS3' regardless of whether I use CS3 or CS4. I guess they didn't update the file)
    --FindChangeList.txt
    --A support file for the InDesign CS3 AppleScript FindChangeByList.applescript
    --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          {find what:"--"}          {change to:"^_"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find all double dashes and replace with an em dash.
    --More complex example:
    --text          {find what:"^9^9.^9^9"}          {applied character style:"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 "find what" and "change to" properties.
    text          {find what:"<b>"}          {change to:"^S"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find all bold and replace with non-breaking space.
    text {find what:"<i>"} {change to:"^S"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find all italics and replace with non-breaking space.

    You probably should post this in the ID Scripting forum. Here's an example of some simple AppleScript find and changes that might help:
    --find and replace keyboard formating
    tell application "Adobe InDesign CS5.5"
         --first clear the preferences
         set find text preferences to nothing
        set change text preferences to nothing
        --replaces non breaking space with space
        set find what of find text preferences to "^s"
        set change to of change text preferences to "<0020>"
        set myFoundItems to change text
        --replaces soft return with return
        set find what of find text preferences to "^n"
        set change to of change text preferences to "^p"
        set myFoundItems to change text
        --replaces return space with return
        set find what of find text preferences to "^p<0020>"
        set change to of change text preferences to "^p"
        set myFoundItems to change text
        --replaces 2 returns with return
        set find what of find text preferences to "^p^p"
        set change to of change text preferences to "^p"
        set myFoundItems to change text
        --replaces return, tab, return with return
        set find what of find text preferences to "^p^t^p"
        set change to of change text preferences to "^p"
        set myFoundItems to change text
        --replaces space, return with return
        set find what of find text preferences to "<0020>^p"
        set change to of change text preferences to "^p"
        set myFoundItems to change text
        --replaces space, space with space
        set find what of find text preferences to "<0020><0020>"
        set change to of change text preferences to "<0020>"
        set myFoundItems to change text
        --replaces 3 tabs with tab
        set find what of find text preferences to "^t^t^t"
        set change to of change text preferences to "^t"
        set myFoundItems to change text
        --replaces 2 tabs with tab
        set find what of find text preferences to "^t^t"
        set change to of change text preferences to "^t"
        set myFoundItems to change text
    end tell

  • Find/change 0065

    in cs5 indesign, when i paste some text into the find/change change to field it looks like this:
    <0065><0088>...
    what am i doing wrong?

    Sounds like it's time to replace your prefs:
    Replace Your Preferences

  • With GREP, is there a way to assign a character find/change to a p style?

    I'm looking for more ways to automate text styling in the magazine I produce. In InDesign, I can assign find/replace command strings in the Find/Change GREP window, but I've found no online source that tells me how to find/replace characters using GREP WITHIN a p style. It seems as if the latter GREP capability is limited to changing character styles and can't search and replace actual characters.
    Example: I have a list of recipe ingredients. I want to replace the quantity (one to three digits) at the beginning of each ingredient with a tab-digit(s)-tab combination. In Find/Change, I can enter "\d+\s" and replace with "\t$0\t" but I don't see a way to assign that capability to a p style. I want this find/change to occur automatically any time copy is added to text tagged with the Recipe Ingredients paragraph style, so I don't have to keep running a Find/Change each time we edit the page. One power user has told me it's not possible. Any insight or alternative solution would be much appreciated.

    Your power source has it right, GREP Styles can only apply character styles to the text it finds.
    And there is no easy way to have text replaced automatically -- you would still need to run a script, or press a hotkey or something.

  • Find/Change - GREP vs. TEXT

    Today, thanks to this amazing forum, I discovered that I had been using "Find/Change" under TEXT, instead of GREP.
    Using "Find/Change" as GREP for finding & replacing seems to be MUCH MORE POWERFUL than "TEXT."
    What are the disadvantages of using "Find/Change" GREP ?  I notice it cannot do "case sensitive" — any other cons?

    GREP searches can be either case insensitive on or off
    case insensitive on:  (?i)
    Case insensitive off  (?-i)
    Example:
    Search for either "case" or "Case"    (?i)case    found on 1st, 2nd and 3rd line
    Search for just "Case"     (?-i)Case    found on 3rd line only

  • Find Change through external text file

    Hello folks
    I am bit pretty in InDesign scripting so could you please look into this.
    How can i change any particular text field in Indesign CS3 document from text file.
    I do have find change script but for each InDesign document specific text file is assigned.
    So each time i have to modify find change GREP property that is also repetetive of work. Is there any way to get find change information should be extract from external text file.
    Many Tanks in advance

    In the FindChangeByList script, you could customize the function myFindFile(myFilePath) {...} as to search the FindChangeList text file in the document location rather than the script location. That's an example. The question is: given a document, where will you have the corresponding FindChangeList?
    @+
    Marc

  • Find/Change Grep only finds one instance per paragraph, where am I going wrong?

    Hi,
    I've been using a Find/Change Grep to find any price with a comma and change that comma to a thin space (Newspaper's editorial style).
    But the Grep only finds the first instance of this per paragraph.
    Sample text...
    "$200,000 $200,000 $200,000.
    text at start of paragraph $200,000
    $200,000 text at end of paragraph
    tab     $200,000."
    In the sample the grep would miss the second and third price on the first line.
    I've been using...
    Find...
    (?<=\$)(\d{3})\,?(\d{3})
    also tried (\$\d{3})\,?(\d{3})
    Change to...
    $1~<$2
    Is there anything I can add to find these last two prices?
    I've been using this in combination with Batch Find Replace script, so different greps are set up for 5,6 and 7 digit numbers that start with $.
    Thanks.

    Try this,
    Find what: (?<=\x{0024})(\d{3})\,?(\d{3})
    Change to: $1~<$2
    Vandy

  • Find Grep in changed from 5.00 to 5.03? (AS)

    Hello,
    Can someone please tell me what I'm doing wrong. This script worked in CS3 v5.00 but now I have tried it in 5.03 and as you can see below it doesn't find anything. I'm using grep to search inside a table for the word "voy" which as you can see from the last line, IS in the table.
    tell application "Adobe InDesign CS3"
    set find grep preferences to nothing
    set change grep preferences to nothing
    set include footnotes of find change grep options to false
    set include hidden layers of find change grep options to false
    set include locked layers for find of find change grep options to false
    set include locked stories for find of find change grep options to false
    set include master pages of find change grep options to false
    set find what of find grep preferences to "(?i)voy"
    find grep row 2 of table id 30958 of text frame id 30954 of page id 30551 of master spread id 30508 of document "Untitled-7"
    get contents of row 2 of table id 30958 of text frame id 30954 of page id 30551 of master spread id 30508 of document "Untitled-7"
    {"vessel", "voy", "eta", "etd", "eta"}
    end tell

    What happens if you change it to to "find grep cells of row..."?<br /><br />-- <br />Shane Stanley <[email protected]>

  • Ignore Line break in find text using grep

    Hi everyone!
    I need to find the text in document using grep.
    find text for :
    Xereptatiuria que alique volo eium qui dolupid ut
    voluptatiam earum saestorepel iuscit im quas et modisimodit.
    The above sentence cannot having line breaks. But document having multiple line breaks.
    so, please to give a tip to find the text using grep.
    I am not excepting this type of result by following.
    Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.  ------------this is not.
    Any another way to find (i.e)., ignore the line break
    simply like this, 
    (?s:Xereptatiuria que alique volo eium qui dolupid ut
    voluptatiam earum saestorepel iuscit im quas et modisimodit.)      --------- the line break wherever it is found,ignore line break in single command.
    Thanks by,
    John Peter.

    johnp45247251,
    what do you really want to do?
    Like pkahrel in your other thread Find Grep And Ignore the line break said:
    pkahrel schrieb:
    You're a moving target: you change your question in each post. Do yourself a favour and go and read up on GREP.
    johnp45247251, one question:
    Could it be possible, that you doesn't understand correctly, how Grep really works?
    <edit by pixxxel schubser>
    Furthermore your example text is different to your screenshot. Your text is:
    »Xereptatiuriaque\n alique volo\neium qui dolupid ut\r voluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«
    And your screenshot shows:
    »Xereptatiuriaque\n alique volo\n eium qui dolupid ut \rvoluptatiam earum\n saestorepel iuscit im quas et\n modisimodit.«
    Normally the text should look like this:
    »Xereptatiuriaque\nalique volo\neium qui dolupid ut\rvoluptatiam earum\nsaestorepel iuscit im quas et\nmodisimodit.«
    Please explain what do you really want to do and exactly if additional spaces are exists or not!
    Could it be:
    you have a text with paragraphs and with many line breaks in that paragraph and there are no spaces exists before or after your line breaks. And is your destination to remove all the line breaks from your text?
    </edit by pixxxel schubser>
    Then the way is not to find the text completly and to ignore the line breaks – the way is to find the line breaks and replace with a space, e.g. like that:
    find:
    \n
    replace with:
    \s
    (change all)
    Regards
    pixxxel schubser

  • Grep find/replace to clean-up texts

    Hi,
    I want to use The ID GREP find/replace to clean-up a imported text with at every line a carriage/return (CR).
    (space)CR -> (space)
    a_wordCR -> aword(space)
    CRCR -> CR
    How can I perform this with Grep expressions ?
    Thanks

    In the first and 3rd replaces, you want a CR replaced with nothing; in the 2nd one, with a space. So it's not possbile to do this with one single "magic" search and replace -- Grep is not magic
    This query will take care of the returns:
    (?<=[\r ])\r
    (replace with nothing). It finds returns with at their left either a return or a single space.
    This one
    (?<=\w)\r
    (replace with space) will change a return after a word character to a space. "Word character" is a bit undefined -- it appears to be at least A-Z (including accented characters), 0-9, and Greek/Cyrillic characters. In case of a problem, you could try
    (?<=[[:alpha:]])\r
    instead -- forcing 'alphabetic' characters only.

Maybe you are looking for