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

Similar Messages

  • Help: apply different para styles to several consecutive paragraphs via script

    Hi all,
    I need to apply different para styles to several consecutive paragraphs via script, something like this (found somewhere on the net):
    var myDoc = app.documents[0];
    var mySel = app.selection[0];
    var myPStyle1 = "A";
    var myPStyle2 = "B";
    //need to add 6 more styles here:
    //var myPStyle3 = "C";
    //var myPStyle4 = "D";
    //var myPStyle5 = "E";
    //var myPStyle6 = "F";
    //var myPStyle7 = "G";
    //var myPStyle8 = "H";
    //the last style not needed in script?
    // apply 1st style to 1st paragraph
    mySel.appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle1);
    // apply styles to paragraphs after selected
    //2nd style
    mySel.paragraphs[-1].insertionPoints[-1].appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle2);
    //next style
    mySel.paragraphs[-1].insertionPoints[-1].paragraphs[0].insertionPoints[-1].appliedParagrap hStyle = myDoc.paragraphStyles.item (myPStyle2).nextStyle;
    I've tried badly, but can't find the way to extend the sequence
    Sorry, no skills in scripting yet...
    all styles have 'Next Style' option activated, but I can't use 'Apply style, then Next style' or Object styles, because I need four different sequences of those para styles:
    A-B-C-D-E-F-G-H
    A-B-D-E-G-H
    A-C-D-F-G-H
    A-D-G-H
    and I really don't want to create special clones of the same style for each sequence (Keep It Simple, they say ).
    I believe it can be done via four slightly adjusted scripts...
    any suggestions would be greatly appreciated...

    Sorry about being late to the party, I usually pick up stuff like this right away.
    How about this one?
    1. No separate scripts needed, it uses a tiny dialog where you can choose what style set to use. If I'm correct, you can press a number key on Windows to immediately select one of the items.
    2. It works down from the paragraph your cursor is in. It has nothing to do with text frames, though -- consecutive paragraphs inside a story always ignore any text frames.
    3. Extensible: you can easily change the names of the styles in the top array, and the number of style groups in the list.
    var styleLists = [
              [ "A", "B", "C", "D", "E", "F", "G", "H" ],
              [ "A", "B", "D", "E", "G", "H" ],
              [ "A", "C", "D", "F", "G", "H" ],
              [ "A", "D", "G", "H" ]
    var radiobutts = [];
    styleDialog = app.dialogs.add ({name:"Set Multiple Styles",canCancel:true});
    with (styleDialog)
              with (dialogColumns.add())
                        with (radiobuttonGroups.add())
                                  for (i=0; i<styleLists.length; i++)
                                            // Build radio button string
                                            str = "&"+String (i+1)+". ";
                                            for (j=0; j<styleLists[i].length; j++)
                                                      if (j) str += "-";
                                                      str += styleLists[i][j];
                                            radiobutts.push (radiobuttonControls.add({staticLabel:str, checkedState:false}) );
    radiobutts[0].checkedState = true;
    if (styleDialog.show())
              for (i=0; i<radiobutts.length; i++)
                        if (radiobutts[i].checkedState == true)
                                  break;
              if (i < radiobutts.length)
                        par = app.selection[0].paragraphs[0];
                        for (j=0; j<styleLists[i].length; j++)
                                  par.appliedParagraphStyle = styleLists[i][j];
                                  par = par.parentStory.paragraphs.nextItem(par);

  • Apple script to build text string

    quick question.. how do i go about building a text string from dialog box results?
    ie 1st question asks for a username second a unix path.
    the put that in a text string to run in a shell script

    Use a construct such as:
    set answer_1 to text returned of (display dialog "Question 1" default answer "")
    set answer_2 to text returned of (display dialog "Question 2" default answer "")
    do shell script answer_1 & answer_2
    (50002)

  • Finder changes Icon List without asking

    Strange behaviour on my new SL mac.
    If I change the Icon List in a folder to, say, Cover Flow, the finder (sometimes?) changes other (all?) folders to Cover Flow. And vice versa etc.
    Obviously I don't want that.
    Is this something I can switch off, or a bug?
    Thanks
    Tom
    PS Another thing that came in with OS9 I think. When you duplicate a file (Apple D) it makes a copy then leaves the cursor in the original label. In the old days it left the cursor in the COPY file - which meant you could change the name without having to reselect. Much better. Is there any way to go back to the old system? (It's been annoying me for years).

    If I change the Icon List in a folder to, say, Cover Flow, the finder (sometimes?)
    changes other (all?) folders to Cover Flow.
    I see the same thing in Snow Leopard, and after some earlier experimenting my own take on this is as follows. I'm not sure it is all correct:
    My understanding is that despite the wording, the View Option setting for "Use as Defaults" was not intended to be interpreted as "Other folders (or even just 'all new folders') will now open in the same view as this one." Rather "Use as Defaults" means "IF a future folder is displayed in the same view as this one, THEN that view will have the same internal parameters as this window does."
    For example, if the current folder window is in List view and you use View Options to change the Text Size from 12 to 14 and then click "Use as Defaults", then IF a future folder is opened in List view, THEN it will also display with Text size 14. If the current folder window is in Icon View and you change the icon size from 64x64 to 108x108 and click "Use as Defaults" then IF a future folder is opened in icon view, THEN it will also display 108x108 icons.
    But clicking "Use as Defaults" doesn't affect WHETHER a future folder will open in a particular view when double-clicked. *The global default for that is simply the last view that was used for a prior folder*, with the exception of particular folders which had been individually set to "always open in xxx view".
    So for example, I just created and opened a new folder on my Desktop, set it to List view, used command-J and altered its parameters somewhat, clicked "Use as Defaults, and closed the folder window. I then created a second new folder, and it opened in List view, as expected. I then set this second folder window to Icon view, and closed it without doing anything else. *I then re-opened the first folder, and it opened in Icon view*, without regard to the "Default" that had been previously set while it was in List view. I then created a 3rd new folder, and it also opened in Icon view, again the "last view used for the prior folder" not the "Use as Defaults" that had earlier been set for the first folder's List view.
    The View Option wording "Always open in xxx view" is also somewhat ambiguous - it actually means "always open THIS folder" in xxx view, not "always open ALL folders " in xxx view. Checking this box will not in itself affect the behavior of any other folder, whether or not that folder has been previously opened. The global default for opening another folder will continue to be the view that was used for the prior folder, and this default can be again be individually overridden for a particular folder by checking that folder's box for "Always open in xxx view."

  • Finder - Browse in List View, Finder - Browse in List View

    In Lion there are now a couple of options are available when you right-click on a Finder window and click on Show View Options:
    Always open in list view
    Browse in list view
    Whereas in Snow Leopard there is only one option:
    Always open in list view
    So my question is, what's the difference between these two new options in Lion? What exactly does "Browse in list view" mean?

    The help file is a bit confusing since it says :
    To set the current window to always open in list view, select “Always open in list view.” If the window has subfolders, you can also set them to open in list view.
    That part where it says that if the window has subfolders, you can also set them to open in List view.  That is what Browse means. So, if you have that checked, when you double-click on a folder in that window, it will open the subfolder in the same view unless that folder has an "always open in ____ View" setting.

  • How to change a list/menu to a text field when 'Other' is chosen?

    Hi there. I've been trying to solve this for a week now and I have depleted all my resources, that is why I'm here. I even went to jquery but nothing works and I think I was over-complicating this way too much.
    In short: I have a contact form, which have a list/menu with validation, and one of the options of that list/menu is "other". What I want is that when the user select "other" automatically change to a text field in order to let the user put his custom color. This is what I have:
    <form method="post" action="process.php">
    <span id="spryselect1">
    <label for="colors"></label>
    <select name="colors" id="colors">
    <option selected="option1">Blue.</option>
    <option value="option2">White</option>
    <option value="option3">Red</option>
    <option value="other">other</option>
    </select>
    <span class="selectRequiredMsg">Please select a colour.</span></span>
    <input type="submit" value="Send">
    </form>
    I know now that the approach is to show/hide a separate textbox besides the other... well. I don't know how to implement that, I think I really need your help guys. I'm completely frustrated.
    Thanks in advance.

    Have a look at the following
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="http://labs.adobe.com/technologies/spry/widgets/selectvalidation/SpryValidationSelect.css" rel="stylesheet">
    <link href="http://labs.adobe.com/technologies/spry/widgets/textfieldvalidation/SpryValidationTextField.css" rel="stylesheet">
    <style>
    .hidden {display:none;}
    </style>
    </head>
    <body>
    <form action="" method="post">
      <span id="spryselect1">
      <label for="colors">Colours:</label>
      <select name="colors" id="colors" onchange="MyOnClickHandler(this.value)">
        <option value="">Please select...</option>
        <option value="blue">Blue</option>
        <option value="white">White</option>
        <option value="red">Red</option>
        <option value="other">other</option>
      </select>
      <span class="selectRequiredMsg">Please select a colour.</span></span><span id="sprytextfield1">
      <input name="other" id="other" class="hidden" type="text">
      <span class="textfieldRequiredMsg">A value is required.</span></span>
      <input name="" type="submit">
    </form>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryDOMUtils.js"></script>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationSelect.js"></script>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationTextField.js"></script>
    <script>
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
    var sprytextfield1;
    function MyOnClickHandler(value) {
         if(value =='other') { //show text field and set validation
              if(!sprytextfield1){
              sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
              Spry.$$('input#other').removeClassName('hidden');
         } else { //hide textfield and destroy validation
              if(sprytextfield1 && sprytextfield1.destroy){
                   sprytextfield1.resetClasses();
                   sprytextfield1.destroy();
                   sprytextfield1 = null;
              Spry.$$('input#other').addClassName('hidden');
         return false;
    </script>
    </body>
    </html>
    Gramps

  • Multi-select and change only certain words in a text box to different font - possible?

    In Word I can select a number of words in a sentence or paragraph by holding the Shift key (PC, natch!) and then bold all of them at the same time, etc. Can't make this happen in inDesign - am I missing something simple?
    Need to take a list like the one below and bold only the dates, using the bold version of the font I'm using - thereby actually changing fonts.
    June 1  Something
    June 25  Something else
    July 24  Something else entirely
    Thanks for any help you can offer.
    Joan

    Hi,
    John is right.
    However, I advise you to take a look at HighlightGrep, [JS] written by Roland Dreger, with an amazing "Live Mode" option that allows you to see the result of a research (before launching it, of course) while you're building your query … simulating your "selection".
    … and, as john said, may be finish the deal with nested styles !

  • Deleting extra forced line breaks with Find/Change

    Ladies and Gentlemen,
    I'm importing word .doc that are text-heavy and the formatting is such that there are lots of extra forced line breaks creating a blank line between paragraphs.
    To avoid manually deleting the extra forced line breaks to eliminate the blank line of space between paragraphs, what are the best steps to doing this an easier way?
    Any advice on clear steps to do it using the find/change option?
    Thanks in advance as always..
    JRH

    Are you talking about two hard returns [Enter] in a row, or a soft and hard return [Shift + Enter] and [Enter]? A forced line break is a soft return, but most Word users would just hit the return key for an empty paragraph to get an empty line.
    In either case, you can do a simple text find change, if GREP intimidates you. Use the special characters menu to enter either two "end of paragraph" or a "forced line break" and "end of paragraph" markers into the find field and a single "end of paragraph" marker into the change field.
    This is included as part of the "Find/change by list" sample script which adds some other common cleanup functions like converting two spaces to one. The advantage to using GREP is it will find any number of consecutive paragraph end markers and convert to one in a single pass, while a text search must be run multiple times to catch the heavy handed author.
    Peter

  • More Find/Change Issues !!

    by script I'm going to create and setup new doc, use a dialog to place a text file, and remove content from the text, format and save.<br /><br />the text file contains old msword-to-pagemaker format tags that I need to delete. the tags are in this format: <br /><br /><PmTags1.0Win><fSouvenir>    etc.<br /><br />I need to delete or convert to indesign cs3 the tags<br />(including "<" & ">" signs). <br /><br />I saved a series of 8 find/change steps to delete the content (text not grep) and need to run them consecutively and through as many as 400 entries<br />(all in the same threaded text box).<br /><br />Supposedly their is a "new" FindChangeByList.jsx somewhere that works, but I am unable to find it. the scripting/index page on adobe's website is useless, and provides no help what so ever. no links either.<br /><br />Any help would be greatly appreciated.

    Hi Seth,
    re: "Supposedly their is a "new" FindChangeByList.jsx somewhere that works, but I am unable to find it. the scripting/index page on adobe's website is useless, and provides no help what so ever. no links either."
    I just looked, and everything is still working. Go to:
    http://www.adobe.com/products/indesign/scripting/index.html
    Then click the Scripting Resources tab.
    Here are the direct links that might be helpful--first, updated sample scripts:
    http://wwwimages.adobe.com/www.adobe.com/products/indesign/scripting/downloads/indesign_cs 3_sample_scripts.zip
    Second, the scripts that go with the Scripting Guide:
    http://wwwimages.adobe.com/www.adobe.com/products/indesign/scripting/downloads/indesign_cs 3_guide_scripts.zip
    In the latter, you should take a look at the ReadPMTags.jsx script (it's in the Text folder inside the JavaScript folder of the uncompressed archive). You can take the function (of the same name) from that script and modify it to do exactly what you want.
    Also, if you don't see links or information at that page--which browser are you using?
    Thanks,
    Ole

  • TIP: Clean slate for find/change

    Hi,
    Sharing a little tip I just thought of. Very straightforward and
    obvious, but quite useful, and I haven't noticed it mentioned elsewhere.
    If you're doing a lot of find/replace, you'll repeatedly need to remove
    all selections and start with a clean slate (nothing in the find/replace
    fields, clear all formatting).
    It seemed to me for a while that we're missing a "Clear All" button in
    the find/replace box.
    So the answer is simple: clear everything, all options, etc., and save
    it as a find/replace query.
    Now whenever you need a clean slate for find/save, just select that query.
    It's working nicely for me!
    Happy new year,
    Ariel

    I was going to stay out of this, but find I can't. Sometimes it seems to me that scripters see everything as being better solved through scripting.
    I actually think Ariel's observation about saving a blank query is quite brilliant, and I have to agree that there are times, and plenty of users like me who don't use a KB hortcut to access find change, where users will find having the saved blank query much faster than any other method of clearing the dialog. Both methods have their place, but I find it disingenuous to say that Jongware's scriptlet "solves" the case where you want to keep the old values -- it actually complicates things as you then must remember if you are to run the KB shortcut, or use the menu, to acieve the desired result.
    I think it would be far better to say that this, like many things in ID, can be accomplished in more than one way, and that they way you do it may be different at different times, and that the mehod of choice is exactly that, a choice subject to the user's own preference.

  • Find/Change object size

    We have a document where each page header/number needs to be changed to a different language. We can find change the text ok but when the text is changed the text box is too small. Unfortunately the headers are not on master pages and the colours vary depending on the background colour.
    How can we do a find/change for the size of the text box?
    We want a text box of size 5mm x 20mm to change to 5mm x 35mm, expanding to the right.
    As far as I can see there is no way to do this with the inbuilt find/change object. Any ideas?

    I think you're doing it a weird way, but who am I to criticise, I've done far weirder things.
    If you don't want to add this to the master page then that's fine, I think you'd be better off and it would make things easier in the long run.
    For changing the width of a frame you'd need a script to that, and I really cannot help you on that one, scripts are not my forté.

  • Find/Change problems within a nested style?

    I have a problem with Find/Change (in both CS4 and CS5) not recognizing text within its “find” parameters when text that fits those parameters is part of a nested style. I want to find any instance of italic in the text, regardless of what paragraph or character style it is, but F/C only intermittently finds italics, both within and without that text existing in a nested style. Has anyone come across this issue?
    There is NOTHING different about the text that is recognized by F/C–or not recognized–that shows up in any of the panels or palettes. There are no font conflicts. I’ve replaced prefs and saved data files. If I go into the character palette and change the italic portion of the nested style to “italic” character style (it shows up in character palette as [none], even though it has a nested style), then F/C finds it for sure; but if I don’t do that, then F/C will sometimes find it, and sometimes not, and sometimes in one instance and not in another! There is no hidden formatting that shows up in story editor. I remade another nested para style with the same formatting but with varying results! Help… I’ve tried everything.

    I have a problem with Find/Change (in both CS4 and CS5) not recognizing text within its “find” parameters when text that fits those parameters is part of a nested style. I want to find any instance of italic in the text, regardless of what paragraph or character style it is, but F/C only intermittently finds italics, both within and without that text existing in a nested style. Has anyone come across this issue?
    There is NOTHING different about the text that is recognized by F/C–or not recognized–that shows up in any of the panels or palettes. There are no font conflicts. I’ve replaced prefs and saved data files. If I go into the character palette and change the italic portion of the nested style to “italic” character style (it shows up in character palette as [none], even though it has a nested style), then F/C finds it for sure; but if I don’t do that, then F/C will sometimes find it, and sometimes not, and sometimes in one instance and not in another! There is no hidden formatting that shows up in story editor. I remade another nested para style with the same formatting but with varying results! Help… I’ve tried everything.

  • Find/Change Glyph won't change fonts.

    Suddenly, huge inexplicable InDesign issue out of nowhere while I'm working under deadline, of course.
    Doing a find and change in the Glyph panel, trying to replace all instances of a carrot symbol in Helvetica to a triangle in Zapf Dingbats. InDesign does the find and change, but keeps the font as Helvetica, so I get the obnoxious box with an X in it.
    WHAT could possibly be causing this, if not just a bug.

    Find
    ^
    Change to
    <leave blank>
    Find Format
    <leave blank>
    Change Format
    Click the box - select the font you want it to change to.
    (note if you have a character style applied to the symbol it may not change)
    To get it to change
    in the find format portion of Find/Change
    Find Format
    Click box beneath and select Character Style
    Change Format
    Click box beneath and select None for character style
    Insert correct font
    Say ok
    Run find change

  • What happened to Find/Change Special Characters

    I am a recent update from FrameMaker 9 to FrameMaker 11. I use many notations with non-breaking hyphens and non-breaking spaces. In version 9 I was able to use the hex codes in the Find/Change dialog box and find and replace those notations. Now in version 11, it does not find those characters. I end up finding more than I want.
    For Example: I want to find
    (E-Vote Sept. 12, 2008)
    This text has a non-breaking hyphen and the spaces shown are non-breaking also. When I entered these characters into the document, I used "Esc hyphen h" key sequence for the hyphen and "Control+space" for the spaces.
    When I enter "(E\x15Vote\x10Sept.\x1012,\x102008)" and press the Find button, FrameMaker converts the text to "(E\+Vote\s#Sept.\s#12,\s#2008)" and returns with a statement "Not Found." I get the same error if I copy the text and paste it into the Find/Change Dialog box. I have tried this with the "Consider Case," "Use Wildcards" and the "Whole Word" checks both off and on. I can't get it to find it.
    Honestly, I never noticed if verstion 9 did the conversion, from \x15 to \+ and \x10 to \s#, in the Find/Change dialog box because it always found what I was looking for.
    I hope someone can tell me how to fix this because this is a function that I use all the time in FrameMaker. I use non-breaking hyphens and spaces all over my documents.
    I have also reported this as a bug because that is what if feels like to me. I did go out and updated my installation of FrameMaker, thinking that this may have been reported and fixed already.
    One Sad FrameMaker User
    Chris

    Chris,
    That's odd. It (dialog-box codes) works for me on my systems:
    Using the dialog-box codes works perfectly. The unicode values for the non-breaking space (nbsp = \u00A0) and non-breaking hyphen (\u2011), however, aren't working. It looks like the wrong glyph is being substituted in both cases.
    This is definiely a bug when doing a unicode-value search.

  • Text or Grep in Find.change script by list?

    Would like to use the grep formating in this query (instead of text) but the script shows error:
    text {findWhat:" )"} {changeTo:")"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}
    Why here coexist two ways of writing?
    How to decide?

    @Laurent: heh heh. After that long story I was still paying attention to the original question...
    Mariana:
    ... as this can combine more characters in a search, for example finding space before point, period, semicolon, etc. Or space after ( or before)...
    Yes, that's possible with GREP. Try this for the first one:
    grep {findWhat:" ([.,:;])"} {changeTo:"$1"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Remove space before period et al.
    (Remember the script needs TABS between the sections, as in the original file.)
    This one is a bit challenging. Actually, the period is a special character in GREp (it stands for "any character"), so normally you would need to escape it:
    (space)\.
    to search for a space followed by a period. However, the square brackets [...] define an OR group, and that removes the magic properties from the period. Apparently, there is no use for a wildcard character in an OR group! (That would be something like, "The following characters are allowed: a comma, a colon, any at all, a semi-colon ...")
    There is a more advanced way to remove spaces like these. You want to look for spaces which are followed by any of these characters, and replace them with nothing. That would be
    {findWhat:" (?=[.,:;])"} {changeTo:""}
    You can try this in the interface to see it works.
    The second can be done using the Unicode value for an ellipsis ("\x{2026}" -- another notation than in the regular Text find), or with the special escape code "~e". Yup -- there is another escape character. The backslash is used by GREP itself, but GREP does not understand InDesign's own special characters -- page breaks, smart single and double quotes, Indent-To-Here, em dashes, and a few others. They can also be inserted from the menu on the right side of the Find field. These characters need a tilde, so InDesign can "translate" them internally to something GREP can use, and GREP never sees them. Since the tilde is nothing special for Javascript, you can safely insert only one in the script data file ...
    To remove a space before or after an ellipsis, you could use this:
    grep {findWhat:" ?~e ?"} {changeTo:"~e"}
    ... but in this case it may again be simpler to stick to regular text mode (where you would use "^e" for the ellipsis, by the way).

Maybe you are looking for

  • HT201335 What causes the TV screen to freeze but sound continue on TV when using Air Play from I Phone?

    What causes TV screen to freeze but sound continue on TV when using Air Play from I Phone 4?

  • F-44 (clear vendor) enhancement

    Hello, eneryone: I have a enhancement requirement: Transaction code: F-44 (program: SAPMF05A, screen: 131), when the Enter key is pressed, Vendor account group of Account (vendor) field should be checked. How can I realize this requirement ? Which en

  • Enable to make payment of invoices against which TDS is deducted

    Hi All, We have posted 3 vendor invoices & deducted the TDS against each invoice as follows - Inv. Amt                            TDS 7516                                158 5050                                107 5051                                

  • Imac (bluebery) cd drive busted

    I'm wondering if I can fix this issue: my cd drive will make click sounds every 3 seconds when i put a disc in, also ive noticed that the optics of the drive on move to the spiner not away from it. it wouldnt turn on before, i fixed that by taking th

  • SETS Issue T-code GR55

    Dear Experts, I have an issue with a SET which is created by me in test systems. I have created the SET using T-code GS01 and assigned the SET to a report. When i am checking the total ALL BA column, the New SET amount is not getting added in the Tot