Adding GREP search to FindChangeByList script in CS4

I'm trying to remove numbers from a baseball box score pulled from the Internet.
The file has 10 numbers across separated by tabs and I only need six of the numbers not all 10
St. Lucie Mets
Player,Pos         AB     R     H     2B     3B     HR     RBI     BB     SO     AVG
Daniel Muno, 2B    4     1     1     0     0     1     1     0     2     .259
Robbie Shields, DH     4     0     2     1     0     0     0     0     1     .471
This GREP search works in FindChange in InCopy/InDesign (using CS4)
(\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d)
This works in the Change field
$1 $2 $3 $7 $8 $9
However, when I try to add this to a FindChangeByList script, it generates an error. So my syntax, logic or both is flawed.
What should I do to fix it?
grep    {findWhat:"(\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d) (\t\d)"}    {changeTo:"$1 $2 $3 $7 $8 $9"}    {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double spaces and replace with single spaces.
Thank you,
Keith

Hi Jongware,
Thank you for the reply.
I tried the double slashes and get an Error 25. So something I'm doing in the Search/Replace portion isn't working.
However, I did have success with changing a style by using a GREP search. The line below works with the double slashes, just not the Find/Change lines:
grep
{findWhat:"\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d"}
{appliedParagraphStyle:"Z BB Box Exp Batting 07T"}
{includeFootnotes:true, wholeWord:false, caseSensitive:false}
//Changes style

Similar Messages

  • GREP in FindChangeByList-script!

    Hi!
    Running the script in IDCS3 and it works well, but...
    I want to use a GREP search and change the Character Style for the result.
    {appliedCharacterStyle:"xxx"} only works if the search is TEXT. How can I make the same work in a GREP line???
    And Yes! I know CS4 will do it without a script, but I need it to work in CS3.
    Suggestions anyone???

    Hi Jongware,
    Thank you for the reply.
    I tried the double slashes and get an Error 25. So something I'm doing in the Search/Replace portion isn't working.
    However, I did have success with changing a style by using a GREP search. The line below works with the double slashes, just not the Find/Change lines:
    grep
    {findWhat:"\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d\\t\\d"}
    {appliedParagraphStyle:"Z BB Box Exp Batting 07T"}
    {includeFootnotes:true, wholeWord:false, caseSensitive:false}
    //Changes style

  • Script or GREP search line for missing quotation marks (opening or closing)

    Hi there,
    I've being trying to figure out a GREP search that will help me find quotations that haven't been opened or closed properly. Does anyone know if there exists a script that will mark/help me find the quotation marks that incorrectly stand alone? A GREP search line would be fine too.
    Following is an example - just to make sure I made myself clear:
    'why is the closing quotation mark missing after the question mark? I asked.
    'I don't know, this line seems to be fine, with opening and closing quotation mark,' I answered.
    Although this line is missing an opening quotation mark.'
    Hope somebody can help me, I'm pretty sure I'm not the first person searching for a solution on this issue - sorry, I'm not to bright with scripting or GREP.
    Thnx.
    Gijs

    As you say, it's not waterproof, but it is really helpfull, thanks. The unclosed quotation are easy to find this way.
    In Dutch we mainly use single quotation marks (double quotation marks are only used for quotations within quotations). This brings an extra dimension to the issue, since the apostrophe and single quotation mark are the same character. So a phrase like ' I'm having problems finding unopened quotations' with your GREP suggestion will mark the apostrophe in I'm as the closing quotation mark.
    So what I'll do is:
    1. find unclosed quotations ‘[^’]+?‘ and mark them with a character style WARNING;
    2. GREP search ’[^‘]+?’ two following closing quotation marks and make them C=100;
    3. GREP search ’[^‘’]+?’ the correct quotations and mark it all K=100;
    4. Do a regular search for '^$ any apostrophe/quotation mark followed by a letter and mark them all K=100;
    5. Do a regular search for any closing quotation mark left in C=100 and manually WARNING-mark the ones that need to be looked at by the editor.
    Step 4 is a bit tricky since any error like 'I agree,'he said (no space after quotation mark) will be marked back to K=100 as well, but those errors I'll probably notice since they're underlined by the grammar control option.
    Thanks again for the help.

  • Question for scripting gurus: GREP search, change case make Smallcaps

    I have no knowledge of scripting at all, but this question keeps coming up during training sessions: is it possible to (java)script this:
    - Do a GREP search \u\u+
    - Change case to lowercase
    - Apply SmallCaps (or: apply character style)
    this would allow to search for acronyms and change them to smallcaps (or, even better: apply a character style with small caps and tracking)
    I know it is easy for OpenType smallcaps (do a GREP search, change to OT smallcaps) but this doesn't really change case. And some fonts used aren't OT.
    Anyone?
    Would be VERY apreciated!!

    But Harbs is a seasoned scripter who knows he'll get flamed if one of his scripts "just does not work" ;)
    Well, now that you mention it, the script is not really foolproof. It's a quick and dirty script which I threw together very quickly. It's missing any error checking, some of the variables global, and it's not in a private namespace. These are all things which could cause it to "just not work" ;-)
    Here's a more foolproof construct... (and it'll work on the current story if selected, or the whole document if there's no story selected) It will create a new character style if one does not exist and work on character styles within style groups as well. I wrapped the whole script in an anonymous function to give it a unique namespace as well.
    (function()
    if(app.documents.length==0){return}
    var doc=app.documents[0];
    // Change the following to your style name!
    var character_style_name = 'Small Caps';
    try{var range = app.selection[0].parentStory}
    catch (err){var range = doc}
    //comment out next line if you do not want styles.
    var charStyle = GetCharacterStyle(character_style_name,doc);
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat="\\u\\u+";
    var finds=range.findGrep();
    for (var i=0;i<finds.length;i++){
    finds[i].changecase(ChangecaseMode.lowercase);
    //comment out next line if you do not want styles.
    finds[i].applyCharacterStyle (charStyle)
    //uncomment next line if you do not want styles.
    //finds[i].capitalization=Capitalization.smallCaps;
    function GetCharacterStyle(styleName,doc){
    var charStyles=doc.allCharacterStyles;
    for(var i=0;i<charStyles.length;i++){
      if(charStyles[i].name==styleName){
       return charStyles[i];
    return doc.characterStyles.add({name:styleName,capitalization:Capitalization.smallCaps});

  • FindChangeByList script to include Style Groups/sub Style Groups

    I've been using this function happily (with varying degrees of success & lots of trial and error) for a while now. I'm not a script writer, understand very little but manage to copy and paste, and hope for the best.
    This has served my wishes for the most part, but I have the need to apply a GREP search/replace to some text that needs to be styled with a paragraph style that lives inside a style group, inside another style group.
    Style group called 'Headings', inside which is a style group called 'News from Areas heads' inside which is a paragraph style called 'b head_red (News from areas)'
    I have picked up on helpful examples from others for applying a paragraph style that lives within one level of "Style Group", but don't know what the correct syntax to describe: a paragraph style within a folder, within a folder, within another folder might be?
    I did wonder if the choice of underscores and brackets in the paragraph style may not help.
    MTIA
    Steve

    Hi Jarek
    Unfortunately I don't have much scripting knowledge, but to answer your questions
    1. paraStyle real name is "b head_red (News from areas)"
        - "b head_red" is used elsewhere. Why didn't I keep it simple?
    2. Do your findWhat string work in UI (run manually)?
        - yes, when I use normal GREP find/change it works okay.
    3. Do your FindChangeByList.jsx work with some simplier example?
        - yes, I use it often. The .txt file I'm working on at the moment already contains about 10 text/glyph changes which work fine. I have had success in applying a 'paragraph style' that is within a 'style group'. But this is the first time I've tried to apply a 'paragraph style' that is in a 'style group', within a 'style group'.
    Steve

  • FindChangeByList script question, re: when a style is part of a style group

    Hi,
    I'm using InDesign's FindChangeByList script and am running into a problem.
    Here is the problem line:
    grep {findWhat:"^."} {appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("Text").paragraphStyles.item("Body2.TextIndent"), changeConditionsMode:1919250519} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true} //Change everything to Text.indent2 style
    What I am trying to do is format every paragraph with the style called "Body2.TextIndent" which is located in my style sheets under a group called "Text"
    This line is not working for me; I get a JavaScript  "Error #17. Error string: variable name expected."
    Please note that I CAN get this line to work just fine if I use a style that is NOT in a group. For instance, this line works fine for me:
    grep {findWhat:"^."} {appliedParagraphStyle:"Body2.TextIndent", changeConditionsMode:1919250519} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true} //Change everything to Text.indent2 style
    The problem is apparently that the FindChangeByList script doesn't like style groups. I found this by Googling the internet and found this link:
    http://www.listsearch.com/indesign/Thread/index.lasso?17986
    Can anyone help?
    Thanks.

    Kasyan, it works for me now! THANKS! One thing... I notice that in your line, you removed the part "changeConditionsMode:1919250519". Maybe that was the problem? I'm new to scripting. What does that line do? Can I leave it out?
    p.s. I'm using CS4 on Windows XP Pro

  • GREP searches from top of story?

    I've set up a GREP expression to find some material I need to delete, but I need to check each instance before I actually delete it. Unfortunately, the GREP expression occasionally finds text that I want to keep, so it's not bullet proof.
    When I first set up my GREP expression, it worked fine -- it would find the next occurrence of the expression after the insertion point when I type a keyboard shortcut for the "GREP Find Next" command.
    Suddenly, and I don't know why, it changed its behavior so that instead of finding the next instance of the GREP expression after the current insertion point, it finds the first occurrence in the story, which is pages away from where I want to be working.
    Is there some way to tell GREP (or any Find search) to look from the insertion point rather than from the top of the document? It seems to have both behaviors as options, but I don't know why it chooses one over the other.

    Well, having done a little more work, I think the problem may result from a look-behind that I added to the beginning of the string.
    Basically, I have about 500 abstracts, each has a long list of authors, with punctuation as follows: SMITH, J.S., affiliation, email; JONES, S.J., affiliation, email; etc.
    I need to get rid of the affiliations, emails, and semicolons; keep the Author name and initials; and apply a script of mine to put the last name in title case, resulting in
    Smith, J.S., Jones, S.J., etc.
    There are some typos and unusual names, so I need to do this one by one rather than with a global search, but I want to be efficient. I want to run my case-change script on the last name, then trigger a GREP search that will select the affiliation and email, which I can then look over to confirm, then delete. (Affiliation may be full of all kinds of punctuation).
    Currently I'm using
    .+?[;\r]
    ...which selects from the insertion point to the next semicolon or the end of the paragraph, whichever comes first. This one works, but I first need to move the insertion point past the initials, which takes more keystrokes.
    Since the author initials always end with a period followed by a comma, but I don't want to delete those, I thought I'd add a look-behind so that the GREP would select all the text from (but not including) a period-comma to (and including) the next semicolon:
    (?<+\.,).+?[;\r]
    The problem is that instead of searching from the insertion point, it goes to the beginning of the file and grabs the first occurrence of the pattern, which is the first already-corrected address (since there are no semicolons left, it selects from just after the first author's initials to the paragraph end).
    Anyway, if anyone has some ideas (including "sorry, GREP just behaves this way with look-behinds") I'd appreciate any help.

  • GREP search crashes InDesign

    Hi,
    I have a script which imports XML and formats it. As part of the formatting, there's numerous GREP searches which remove redundant spaces, returns and so on.
    One in particular crashes InDesign and it's driving me nuts.
    It's supposed to remove redundant returns in a table:
    // GREP Search for redundant returns
    app.findGrepPreferences = app.changeGrepPreferences = null;      
    app.findGrepPreferences.appliedParagraphStyle = "ArticleMinister";
    app.findGrepPreferences.findWhat = "\r$";
    app.changeGrepPreferences.changeTo = "";
    app.activeDocument.changeGrep();
    The problem is there's an XML closing tag between the carriage return and the end of the para, i.e. data{return}</closingtag>, but it works fine when the XML is data</closingtag>{return}.
    Any assistance would be most appreciated.

    Hi Vamitul,
    Thanks very much for the reply and it makes perfect sense.
    This script creates quite a complex document and, for some reason, moving the {return} outside the XML tags makes a mess of the document. I do not know why but I suspect that some of the 'clean up' non-GREP search and replace commands in the script are ignoring the XML data - perhaps not but I cannot for the life of me work out why a simple change is making the text a real mess.
    So the 'harder fix' sounds like something worth pursuing as this is the last step in a long process. Do you have any more information about checking the xmlContents? I don't expect anyone else to do my work for me, but advanced (or even intermediate) scripting is something I struggle with.
    Cheers,
    Simon.

  • Powershell script assistance - adding another property to existing script

    This is not my script but was written by Richard L. Mueller. It works perfectly for us but I would like to know if the account is enabled or disabled when the output is created. Basically it would output the name, lastlogon and then either enabled or disabled.
    I've attempted to add a new property by adding another " $Searcher.PropertiesToLoad.Add" and "$Result.Properties.Item ".
    It works fine if I add something like "givenName" but I can't find the property name to show if the account is enabled or disabled.
    The entire script is shown below:
    # PSLastLogon.ps1
    # PowerShell script to determine when each user in the domain last
    # logged on.
    # Copyright (c) 2011 Richard L. Mueller
    # Hilltop Lab web site - http://www.rlmueller.net
    # Version 1.0 - March 16, 2011
    # This program queries every Domain Controller in the domain to find the
    # largest (latest) value of the lastLogon attribute for each user. The
    # last logon dates for each user are converted into local time. The
    # times are adjusted for daylight savings time, as presently configured.
    # You have a royalty-free right to use, modify, reproduce, and
    # distribute this script file in any way you find useful, provided that
    # you agree that the copyright owner above has no warranty, obligations,
    # or liability for such use.
    Trap {"Error: $_"; Break;}
    $D = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $Domain = [ADSI]"LDAP://$D"
    $Searcher = New-Object System.DirectoryServices.DirectorySearcher
    $Searcher.PageSize = 200
    $Searcher.SearchScope = "subtree"
    $Searcher.Filter = "(&(objectCategory=person)(objectClass=user))"
    $Searcher.PropertiesToLoad.Add("distinguishedName") > $Null
    $Searcher.PropertiesToLoad.Add("lastLogon") > $Null
    # Create hash table of users and their last logon dates.
    $arrUsers = @{}
    # Enumerate all Domain Controllers.
    ForEach ($DC In $D.DomainControllers)
    $Server = $DC.Name
    $Searcher.SearchRoot = "LDAP://$Server/" + $Domain.distinguishedName
    $Results = $Searcher.FindAll()
    ForEach ($Result In $Results)
    $DN = $Result.Properties.Item("distinguishedName")
    $LL = $Result.Properties.Item("lastLogon")
    If ($LL.Count -eq 0)
    $Last = [DateTime]0
    Else
    $Last = [DateTime]$LL.Item(0)
    If ($Last -eq 0)
    $LastLogon = $Last.AddYears(1600)
    Else
    $LastLogon = $Last.AddYears(1600).ToLocalTime()
    If ($arrUsers.ContainsKey("$DN"))
    If ($LastLogon -gt $arrUsers["$DN"])
    $arrUsers["$DN"] = $LastLogon
    Else
    $arrUsers.Add("$DN", $LastLogon)
    # Output latest last logon date for each user.
    $Users = $arrUsers.Keys
    ForEach ($DN In $Users)
    $Date = $arrUsers["$DN"]
    "$DN;$Date"

    It is part of the userAccountControl attribute. Retrieve that attribute for each user and test if the ADS_UF_ACCOUNTDISABLE bit (2) is set.
    -- Bill Stewart [Bill_Stewart]

  • Excluding a character from "Change to" box that is in "Find what" box in GREP search

    Hello all! I am a first time poster but have been lurking around the forums for a few months. I'm trying to produce an InDesign document for a book I'm putting out, and there is a section where I have the following text:
    |  TAB  |1.|  TAB  |Lorem ipsum dolor etc.
    The text doesn't literally say tab, I jsut wanted to highlight that there is a tab of white-space on either side of the number for the line. This occurs numerous times in numerous chapters in the endnotes section. I want to remove the tabs so that the result is:
    1. Lorem ipsum dolor etc
    2. Lorem ipsum dolor etc
    3. etc etc
    I have identified that the way to find these sections is to use the GREP search function with \t\d+.\t. The + is there because the numbers go into the double digits in most chapters for the references. However, I do not want to remove the numbers, just the tabs. Is there any way to add an exclude feature to the "Change to" window of the search function? I've tried just leaving it as \d., but that literally changes the text to
    \d. Lorem ipsum dolor etc
    That's not good. I'm trying to avoid having to do all of this by hand, and of course by the time I get a resolution I'll probably have been better off doing it manually, but I'm looking toward the future and trying to ascertain the best way of streamlining such a process short of not having that kind of format in the first place when receiving the file from my employer
    Many thanks for your advice,
    David

    Peter,
       Just to affirm your assistance, this worked for me. I still don't understand the advanced search features perfectly, but I got the formatting fixed without having to sift through it manually. I found that replacing with "$2. " (minus the quotes) worked well. However, I noticed that searching for (\d). would turn up a digit followed by ANY kind of punctuation, not just a period. I assume therefore that . must mean something different in GREP than I'm thinking it does. I just wanted to find any digit before a full-stop. At any rate, that is something I can find a table of GREP search terms for. I didn't understand the $2 thing until I monkeyed with it. I'm typing now for future generations of newbies that might stumble upon my post. The $2 ignores the second character in your "Find what" field. So for example, if instead you had two tabs then a digit then a tab, you could search:
    Find what: (^\t)(\t)(\d)(\t)
    Change to: $3.
    This would take any occurrence of two tabs, a number, and a tab and replace with a period, ignoring and therefore not changing at all the number. The $3 is saying "ignore the third search term", in this case, the \d.
    A better approach would be to use +. This means "any time you see one or more occurrences of the searched-for character". This would look something like:
    Find what: (^\t+)(\d+)(\t+)
    Change to: $2.
    Here you are saying "Any time you see one or more tabs followed by one or more numbers and then followed by one or more tabs, ignore the digit, delete the tabs before and after, and add a full stop after the number. This is a very powerful search feature, once you understand what you're doing anyway. Hope that is helpful to someone at some point.

  • Using footnote markers in a GREP search

    In a 300 page document, with hundreds of footnotes, I want to insert thin spaces between single endquotes and footnote markers. The easiest way seemed a GREP search and repace. I search for (\’)(~F) and replace it with $1~<$2. The result is ’ ’ (endquote-thin space-endquote). When I try to replace AB to A-thin space-B in the same way, the result is right. So what's going wrong? (I also tried ~] for the endquote.)
    (By the way, I have a workarround, but I'd like to understand how GREP searches work.)

    Footnotes aren't really a part of the semi-official GREP definitions, and I imagine the Adobe programmers had to fix a couple of workarounds to make them work at all. They are not simply single characters (quotes, spaces, and possibly text variables are) but "contain" lots of other information, just like anchored objects do. That could be the reason they don't Play Nice with regular GREP operations.
    In this particular case, you can work around it searcing for but not replacing the footnote marker code. Look for
    (\')(?=~F)
    and replace with
    $1~<
    The combo (?=~F) will find but not include the footnote code, and thus nicely circumvent the problem.

  • [CS3] GREP search first ocurence only

    Hi!
    I have an alphabetical list:
    Asdfg
    Awert
    Bsdfg
    Bwsd
    Csdfg
    Cwsd
    etc
    Is it possible to grep search first occurrences of A:s, B:s, C:s etc and then apply some formatting?
    ie search first line that starts with A, apply formatting, ignore following lines witch start with letter A and search first line that starts with B, apply same formatting...
    Thanks

    Oh allright, this one sets the paragraph style "Index head" as well.
    nextpar = app.activeDocument.selection[0].paragraphs[0];
    do
    nextletter = nextpar.contents[0].toUpperCase();
    nextpar.insertionPoints[0].contents = nextletter+"\r";
    nextpar.insertionPoints[0].appliedParagraphStyle = "Index head";
    while (nextpar.contents.length > 0 && nextpar.contents[0].toUpperCase() == nextletter)
      if (nextpar == nextpar.insertionPoints[-1].paragraphs[0])
       exit(0);
      nextpar = nextpar.insertionPoints[-1].paragraphs[0];
    } while (nextletter < "Z");
    It's surprisingly slow, on a 3 column/4 page index... but it still beats doin' it manually, 'cause you can sit back and clean your fingernails or something like that.

  • Add search area in script

    Hi,
    In the Navigator, I would like to add or remove search areas with script. This script will be launched at the DIAdem start to automatically configure the datafinder and update the search area. I don't find the way to do it. Could anyone help me ?
    Thanks in advance.

    Hi bull balls,
    Unfortunately, there is no command available in the DIAdem 11.0 time frame with which you can programmatically configure the DataFinder.  We have received requests of this sort in the past and are considering options on this front moving forward.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Adding elementry search help to SAP standard Collective Search help

    Hi,
    I had copied standard elementary search help to MAT0M to ZZ_MAT0M and added some more fields and activated to it.
    it got activated sucessfully.
    Now i have to attached the ZZ_MAT0M elementry search help to standard collective search help MAT1_A.
    How can i do that?
    can i add it directly to MAT1_A (sell --->search help <MAT1_A> changes --> in included search helpss tab using + (insert icon) )
    Thanks & regards

    I solved my problem :
    I had copied standard elementary search help to MAT0M to ZZ_MAT0M and added some more fields and copied Database View M_MAT1M to ZZ_M_MAT1M and addedd same fields and  activated both.
    both got activated sucessfully.
    Now i have to attached the ZZ_MAT0M elementry search help to standard collective search help MAT1_A and this Z-search help shd appear on the first tab.
    so I just went to collective search help MAT1_A in change mode --> click on "+" icon addedd my ZZ__ search help, save and activated it.
    If you dont really care in which tab your search help shd appear, then the best option is to use Append Search help.
    Note : if you are directly adding your search help in collective standard search help, then its better to remove hotkey form your custom elementry search help, as, if not remove will lead to warnings or make sure that you have unique hotkey in that collective search help.

  • GREP Search - Save to file

    Hello,
    I wonder if it's possible to do a GREP search in an Indesign CS3 document, then save the results to file (like .csv).
    Thanks
    Marco Lugli

    Sure it is possible.
    Assign your found texts to a variable, write the variable to a text file.
    myVar = "";
    // add text to variable
    myVar += "text\tsecondtext\n";
    newFile = new File ("~/Desktop/mycsvfile.csv");
    newFile.open('w');
    newFile.write(myVar);
    newFile.close();

Maybe you are looking for

  • My 15-inch, Mid 2010 Macbook Pro keeps restarting

    Sorry if this has been asked here before but I've been having lots of trouble with my Macbook Pro lately and I'm not sure what to do. It keeps restarting all the time and I've noticed that it mostly occurs while I'm using the Type Tool in Photoshop.

  • Component for JSF Save as dialog Box

    Hi I would like to have a save as diolog box in my JSF based Web application I am using richfaces as the implementation.. Can anyone give some valuable points about how to implememt that..............

  • Can't drag photos to page

    With iWeb '09 I can't drag photos from iPhoto events. It worked with iWeb '08 very well. How do you reset iWeb '09? Milan

  • My Nokia app doesnot open at all

    My Nokia (n) app doesnot open so dn't kno wat to do

  • Connect computer to phone as an audio gateway

    Is it possible to have all audio from my E90-2, sent through bluetooth to my computer? Instead of connecting a bluetooth headset to my phone, I would like to be able to connect my computer to my phone. I am able to get the phone and computers to conn