Find and replace paragraph style

I am creating a javascript for InDesign in order to search and replace some text. The text I am looking for has to be in a certain Paragraph style.
This is what I have so far:
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = '^p'
app.changeTextPreferences.changeTo = ';'
app.activeDocument.changeText();
I need to find/change a return of a certain paragraph style to a semi colon. What is the script that I would use to search for paragraph style?

try:
app.findTextPreferences.appliedParagraphStyle = 'para style';
If you want to replace the para style, use:
app.changeTextPreferences.appliedParagraphStyle = 'new para style'

Similar Messages

  • Find and replace by text and style

    We have a fairly large RH HTML project (300+ topics so far)
    most of which have a specific heading in Heading2 style. We want to
    change all of these to a style based on Heading2, but not use the
    Heading2 style b/c we don't want them to show up in the TOC. I have
    created a new style and can obviously open every topic and manually
    select and change each one - but I'm hoping that one of your RH
    gurus will tell me an easier way. Is there anything comparable to
    MS Words Find/Replace that will search the whole project for a
    specific word in a specific style?

    RoboHelp's Multi-File Find and Replace (in the Tools tab)
    should be suitable for this job, and you can control each
    occurrence as you choose. (Where this RH utility fails is when your
    search string might sit on more than one line, which won't be the
    case here.)
    You'll run two replacement passes (spaces added to < &
    > tags for proper viewing in this forum):
    Replace < h2 > with < p class=YourNewStyle >
    Replace < /h2 > with < /p >
    The < h2 > and < /h2 > strings will never be
    split between lines, so RH will catch every one.
    BTW, Add me to the list of FAR boosters; it'll let you change
    case, change file names, etc., etc., etc. Great tool!
    Good luck,
    Leon

  • Find and replace a table style

    I have about 10  table styles in a document and I want to replace all of them with the #1 table style. Can this be done with Find and Replace?

    You'll need to do this for each of the Table formats that need to be replaced.
    Let's assume the desired format is "Format A" (a default FM style), and one of the formats to be changed is "Specs 2".
    Click in any instance of a Specs 2 table.
    In the Table Tag field, pull down and click on [Format A].
    Click Commands > Global Update Options:
    (*) All Properties
    (*) All Tagged [Specs 2]
    [Update]
    If it works properly, you'll get a dialog:
    OK to change all Format B tags to Format A?
    [OK]
    Additional global updates may be required to clean up any overrides.
    Trying this on FM7 at home, it didn't always work. I don't know if newer versions are more stable. Personally, I never do it this way (probably because of prior experience), and I usually just hack the MIF.

  • Do there is any way to redefine styles by find and replace or script

    I have a some styles and i want  to change same things in all styles like language, align and numbers digit and etc....,
    So I ask if  there is an easy way  to do that except modify each style manual, like script?, I use inDesgin CS3, and CS4
    Like in Find Font there is option to redefine styles but that for fonts only, So there is way to do that by find and replace ?
    Thanks

    I'm not a "scripter" and I don't have a huge knowledge of what scripts are available, unlike some on here, but this is how I'd do it if I couldn't find what I wanted by googling.

  • Rename Layers: Find and Replace style renaming

    In Illustrator, you can use the following to find and replace layer names:
    var doc = app.activeDocument; 
    // name indexed object 
    var layernames = { 
    'Bob':'Bob Front'
    // loop through all layers 
    for (var i = 0; i < doc.layers.length; i++) 
    //Set up Variable to access layer name 
    var currentLayer = app.activeDocument.layers[i]; 
    if (layernames[currentLayer.name]) 
      currentLayer.name = layernames[currentLayer.name]; 
    In this script "Bob" will become "Bob Front". Is there something similar for Photoshop. Looking at the Photoshop scripting guide, this script should work as the active App document and layers methods exist in Photoshop.

    c.pfaffenbichler wrote:
    What are
    var layernames = {
    'Bob':'Bob Front'
    and
    if (layernames[currentLayer.name])
    supposed to do? Is that even JavaScript? …
    Hi c.pfaffenbichler, yes, this is pure Javascript.
    Try this little example:
    var layernames = {'Bob':'Bob Behind'};
    alert(layernames['Bob']);
    // a variant
    layernames['Bob'] = 'Bob in the middle';
    alert("a variant:  " + layernames['Bob']);
    // another variant
    layernames.Bob = 'Bob Front';
    alert("another variant:  " + layernames.Bob);
    @big_smile,
    your posted script works with photoshop (if you have only artlayers and one or more layers named with Bob)
    var doc = app.activeDocument;
    // name indexed object
    var layernames = {'Bob':'Bob Front'};
    // loop through all layers
    for (var i = 0; i < doc.layers.length; i++) {
        //Set up Variable to access layer name
        var currentLayer = app.activeDocument.layers[i];
        if (layernames[currentLayer.name]) {
            currentLayer.name = layernames[currentLayer.name];
    All you have to do is to loop trough all artlayers (and layersets), but here is Javascript a slowly variant. Use ActionManager code instead. You will find many examples here in forum.
    Have fun

  • How can i find and replace xml tags?

    Hi, i am using xml in my workflow and want to be able to remove certain tags if they contain particular text.
    here is an example of my xml structure…
    <entry>
        <name>DEFAULT</name>
        <tel>DEFAULT</tel>
        <address>DEFAULT</address>
    </entry>
    I am using this initial structure to set the paragraph styles to be followed when the xml data is imported.
    This leaves DEFAULT in place wherever an entry doesn't have any content for that field.
    I want to be able to import my XML then run a script that removes any tags that include DEFAULT, - I need the entire xml tag to be removed not just the text, if i do a normal find and replace it will only remove the text not the tags which is causing problems with styling. I also want to remove the end of para/return (^p) that i've placed at the end of the line. So it would be the same as opening up story editor and removing the content + tags + hard return in there, but i want to automate the process…
    So i think this is what i need to search for in each case
    "<name>DEFAULT</name>^p"
    and i want to replace it with nothing ""
    Can this be done through scripting (ideally javascript)?
    I have a little knowledge of javascript but am not sure how to search and target that kind of string in indesign...
    using indesign cs5
    many thanks

    Hi,
    Script should do it in two steps:
    1. find all occurences of i.e. ">DEFAULT<"
    2. remove whole paragraph which is a found_text's container.
    For example this way -JS - (a textFrame filled with your text should be selected) :
    var mStory = app.selection[0].parentStory;
    app.findTextPreferences =  null;
    app.findTextPreferences.findWhat = ">DEFAULT<";
    var myF = mStory.findText();
    var count = myF.length;
    while (count--)
         myF[count].paragraphs[0].remove();
    rgds

  • Search and replace nested style in JS CS3

    I need to find and replace numbers at the beginning of paragraph which is styled as nestedStyle. What is the code? ST Dishon

    Hi dishon,
    I have attached the script to convert the applied nested styles to character style.
    After that you can easily do what you required.
    Regards,
    Ramkumar .P

  • JTextPane Find and Replace

    I'm trying to do a find and replace in a JTextPane. It's successful except that all the formatting is lost. I assume it's because getText() and setText() don't keep the styles. Any help would be greatly appreciated.
    Scott
    package mainPackage;
    import javax.swing.*;
    import javax.swing.text.*;
    public class MyTextBox extends JTextPane {
        private String before = null;
        public void swap(String[] keys, String[] replacements) {
            if(keys == null || replacements == null) {
                return;
            if (before == null) {
                try {
                    before = this.getDocument().getText(0, this.getDocument().getLength());
                } catch (BadLocationException e) {
                    e.printStackTrace();
            String after = new String(before);
            for (int i = 0; i < keys.length; i++) {
                after = after.replaceAll(keys, replacements[i]);
    this.selectAll();
    this.replaceSelection(after);
    repaint();

    I revise my earlier statement.
    select() and replaceSelection() didn't handle the attributes correctly. The inserted text picked up the attributes of the next character. I think - this is still really sketchy for me. If I replaced a word that was underlined (for example), the replacement would pick up the attributes of the space immediately after the word. If the space was underlined, the replacement was underlined, and if not, then not.
    The following seems to work, though I haven't really done anything with paragraph attributes yet:
    try {
        setCaretPosition(pos); // where pos = position of first character of the string to replace
        AttributeSet ca = this.getCharacterAttributes();
        AttributeSet pa = this.getParagraphAttributes();
        this.getDocument().remove(pos, keysString.length());
        this.getDocument().insertString(pos, replacementString, ca);
        this.getStyledDocument().setParagraphAttributes(selection[0], replacementString.length(), pa, false);
    } catch (BadLocationException e) {
        e.printStackTrace();
        System.exit(-1);
    }I've also added the Dukes back and will be assigning them now to you two guys that helped, even though I didn't originally think you had :)
    Thank you.

  • Replace paragraph style [JS]

    Hi All,
    (1)
    I have a JS code for replace paragraph style (come word file (floppy style)) its working good. But my problem is that when run this code if find paragraph style not define (word file (floppy style)) in flow indesign file then error. Is that possible if paragraph style not find then ignore then run next step. Please see code below
    var myDocument = app.activeDocument;
    var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
    myParagraphStyleA.remove(myDocument.paragraphStyles.item("1H: One Head"));
    (2)
    You have any script for delete only unused  (para/char (Floppy style)) only.
    Thank you so much adv.
    regard
    snegig

    Hello Sir (Harbs, Jongware and other),
    I am really sorry for late answering. I am junior so heavy workload.
    This line code "h1" paragraph style actually comes ms-word file (floppy style).
    var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
    Second line code "1H: One Head" is InDesign CS4 paragraph style.
    var myParagraphStyleA = myDocument.paragraphStyles.item("h1");
    If "h1" PS comes (ms-word) in InDesign then code run good. In case if "h1" PS not comes in InDesign file then script error.
    I have just mapping both Paragraph Style (PS) (ms-word, InDesign) if both styles mapping then script run. When run same script other chapters if any tag not come form (ms-word) but whose PS define in script then script error.
    My question is that if any PS comes from (ms-word) if this style not define in script, script run properly otherwise script display massage these PS (ms-word(floppy)) not define in your script code.
    (2) My second query
    If all PS mapping by script but ms-word style (floppy) appear in my indesign file. Is that possible these PS replace (mapping) ms-word style (floppy) automatically remove.
    Thank you so much
    Regard
    snegig

  • Find and Replace Issue Help Requested.

    Hi all. I've been digging around for a couple of days and
    can't seem to figure this one out. For starters, I have already
    looked at the Regular Expression syntax and tried the MS word
    clean-up option, but no luck. We have about 1,500 pages of content.
    They are in DNN, so the pages are created dynamically.
    Unfortunately, the page content was written in Word and then dumped
    in DNN. We are trying to clean up the pages. We are grabbing the
    content from Dot Net Nuke and putting it into Dreamweaver 8.0.2.
    Then we are manually cleaning out things like:
    <?xml:namespace prefix = o ns =
    "urn:schemas-microsoft-com:office:office" />
    and
    <P class=MsoNormal style="MARGIN: 0in 0in 0pt"
    align=left>
    We are using the Find and Replace funtion in Dreamweaver to
    clean out these commands, but I know from the documentation, there
    is an easier way to clean these pages.
    Bottom Line: Since the pages are dynamically built, I know I
    have to grab the page content and put it in Dreamweaver manually
    and then put it back in DNN, but I am trying to find a way (using
    Regular Expressions or something) to look for all the little
    variances of MSO, <?XML, etc. in a straight shot. I would like
    to find a way to use a wild card to look for all tags that have MSO
    or Microsoft or ?XML in them and then replace them with a null
    value. From what I can tell, the Find would have to use a wildcard
    because the advanced find features don't carry what I am looking
    for. Something like Find \<?xml * [<-wildcard] to \> to
    grab the entire tag. The Find tag command doesn't work because the
    tags I need aren't listed. Also, because the content is dynamic, I
    can't do a Fins and Replace against the entire site for these
    commands, but it would be nice to "Find" all of these items with a
    single pass since the "Replace" value is always null.
    The wildcard syntax and multiple Find instances are the main
    questions. The wildcards seem to be character or space specific.
    Sorry for the long explanation - I just don't want to waste
    anyone's time typing responses to things I've already tried to do.
    Thanks in advance for any help. This is my first time back in
    the forums in about 4 years.

    sadamec1 wrote:
    > Well David, you Findmaster - it worked! (At least it
    found and highlighted the
    > code). Now, I need to dig through what you sent me and
    compare it against my
    > regular expression definitions to find out how to grab
    the rest of these
    > phrases. You're the best. Thank you!
    Glad that it did the trick. Just to help you understand what
    I did,
    there are two main sections, as follows:
    <\?xml[^>]+>
    and
    <[^>]+(?=class=Mso)[^>]+>
    They are separated by a vertical pipe (|), so they simply act
    as
    alternatives.
    The first one searches for <?xml followed by anything
    except a closing
    bracket until it reaches the first closing bracket.
    The second one is more complex. It begins with this:
    <[^>]+
    This simply looks for an opening bracket followed by anything
    other than
    a closing bracket. What makes it more intelligent is the next
    bit:
    (?=class=Mso)
    This does a forward search for "class=Mso". It's then
    followed by this
    again:
    [^>]+>
    That finds anything except a closing bracket followed by a
    closing bracket.
    The bit that you need to experiment with is (?=...). It's
    technically
    called a "forward lookaround". The effect is that the second
    half of the
    regex finds <....class=Mso....>.
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • Find and Replace HS5.5

    How do I include a line feed in the replace section of the
    find and replace feature of Homesite 5.5?
    Converting many lengthy files from <pre> and <tt>
    formats into CSS. Presently the target pages have paragraphs broken
    into short lines of text with CR/LF's on every line. I wish to
    revert the paragraph back to 'wrapped' text with a single CR at the
    end of the paragraph.
    I can 'find' and eliminate the " ¶ " symbol from each
    line, but I do not know how to "replace " text that should include
    this symbol.
    text</p><p>¶
    This is some sample text to¶
    show graphically the problem¶
    I am having.</p><p>¶
    New Paragraph¶
    When what I want is :-
    <p>This is some sample text to show graphically , the
    problem I am having.</p>¶
    <p>New paragraph
    Presently I can add hash marks (##) where I wish the
    paragraph to end. I then globally remove all the "¶"'symbols
    that appear in the text. What I want to do now is replace the ##
    with code which would produce the following two lines
    </p>¶
    <p>
    I have tried many different codes, such as chr(13) and \r,
    but they all just insert the code as straight text.
    Can anyone clue me in?
    Thanks, gil d

    as far as special chars in simple F-and-R, I replace some
    non-ascii chars by copying from a doc and pasting into the dialog
    field.
    That wouldn't work for CR/LF, so you have to use the extended
    search and replace there as you found out.
    Note there is also a function for "Replace Double Spacing
    with Single Spacing" (on the menu, under Search).
    Probably no help for this case, but good to know.
    BTW, be careful with your extended search and replace on
    CR/LF. If your lines don't end in a space and a CR/LF, you might
    want to replace CR/LFs with a space. Otherwise the last word of one
    line might be butted against the first word in the next line with
    no space when the CR/LF is removed.
    Of course that's not a great solution since it adds a lot of
    spaces where you have CR/LFs, and you may not want them all
    there...
    There is a Remove Returns script that might be of use to you.
    It's a lot more manual than you probably want for doing lots of
    files.
    http://www.wilk4.com/asp4hs/list5.htm#removereturns
    let us know here if you find some better solution please,
    good luck,
    jeff

  • Find and Replace in RH HTML

    After upgrading to RH8, all instances of "em dash" symbols in projects are now appearing incorrectly. When we insert the "em dash" symbol, we always eliminate any spaces before and after the symbol. All projects that have been upgraded to use RH8 now add a space after the symbol, which is incorrect.
    I have also installed the RH updates and opened a project that had not been upgraded before the update installs...same problem.
    Due to the size of the projects, I have tried using the Find and Replace feature within the HTML view; unfortunately, this did not work.
    Has this issue been addressed with Adobe? I ran into a similar issue with the upgrade to RH7, where the HTML coding for em dashes would come through in the design view and final .chm output file. Does anyone know of a Find and Replace feature within RH that will allow me to remove every instance where a space appears after the em dash symbol? I have found the FAR tool but would like to avoid it if possible, as I have read it can corrupt RH files.

    There was one other post recently about this but otherwise this problem had gone quiet so I don't know why you are seeing it in a project that was not opened before applying the patches.
    So turning to FAR, it is not the program that corrupts files. It is what the user does with it. As we usually say, it can fix a project in minutes and wreck it in seconds. That is because the user has not thought about what the search might find. For example, you might search for "class" thinking about your topic content but of course FAR works a code level so it will remove all your style classes as well. That is where the corruption comes in, not the software itself. It's rather like blaming the car for the crash.
    If you back up first, there is nothing to lose.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • VBA Word Find and Replace characters but excluding certain characters

    I am trying to write VBA code in Word that I will eventually run from a VBA Excel module. The aim of the project is to find specific strings in the open Word document that have length of either one or two characters and are of a certain format, and replace
    them with other strings in the same format. This is to do with transposing (i.e. changing the musical key) of chord symbols in a songsheet in Word. The Find and Replace strings are contained in ranges in an Excel workbook, which is why I want to eventually
    run the code from Excel. I'm much more experienced in writing VBA code in Excel than in Word, and I'm fairly confident with transferring the 'Word VBA' code into an Excel module.
    At the moment I'm trying out code entirely in Word, and I've come across a stumbling block. For example, I want it to Find "A" and replace with "B",
    BUT only if the "A" is NOT followed by "#" (sharp) or "b" (flat).
    Here is the code I've got in Word VBA, which I obtained by editing code produced by the recorder:
    Sub F_R()
    'Find text must have specific font
    With Selection.Find.Font
    .Bold = True
    .Underline = wdUnderlineWords
    .Superscript = False
    .Subscript = False
    End With
    'Replacement text must have specific font
    With Selection.Find.Replacement.Font
    .Bold = True
    .Underline = wdUnderlineWords
    .Superscript = False
    .Subscript = False
    End With
    'Find & Replace strings
    With Selection.Find
    .Text = "A" 'hard-coded here for testing, but this will
    'eventually be referenced to a cell in Excel
    .Replacement.Text = "B" 'hard-coded here for testing, but this will
    'eventually be referenced to a cell in Excel
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = True
    .MatchWholeWord = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    For the Find & Replace section I want to do something like:
    With Selection.Find
    .Text = "A"
    .Text <> "A#"
    .Text <> "Ab"
    .Replacement.Text = "B"
    End With
    - but this produces a syntax error, presumably because you can have only one .Text line (or it won't accept <>?)
    I tried adopting the way of excluding chars when using the Like operator, and while it compiles, it will not replace
    any "A":
    With Selection.Find
    .Text = "A[!b#]"
    .Replacement.Text = "B"
    End With
    I suspect that I'm going to have to change tack completely in the way I'm doing this. Do you have any suggestions, please?
    The chord names/symbols are preceded/succeeded by either spaces or paragraph returns and can look like these, for example (all Font Bold and Underlined words only):
    C<sup>7</sup>
    Dm<sup>7</sup>
    Eb<sup>-5</sup>
    Bb<sup>+11</sup>
    F#m<sup>7</sup>
    i.e. [ABCDEFG][b # | optional][m |optional][- + | superscript, optional][2 3
    5 6 7 9 11 13 | superscript, optional]
    The crux of my problem is that the note A should be treated as entirely distinct from Ab or A# (and similar for other flattened/sharpened notes).
    Sorry for long post.

    Hi Ian,
    It is not easy to find Microsoft forums. However this forum is for the Visual Studio Net version. 
    Try this forum for VBA.
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba
    Success
    Cor

  • Batch Edit Multiple HTML files | Find and Replace

    Hi,
    I would like to use Automator to automate (I know that sounds redundant) the following process.
    1. Take a group of html files
    2. Open each file so it can find and replace the script of any image folders
    Example:
    Change: img src="home_files/photo.jpg" to img src="images/photo.jpg"
    3. Save & Close each file
    I assume this this would have to be done in either AppleScript or Cocoa.
    Any help would be greatly appreciated.
    Thanks in advance.

    you most definitely don't need Cocoa for something like that. if all you need is a straightforward search and replace in a bunch of html files you can easily do this with a shell script. If you need some more involved search and replace you have to explain what it is exactly that you want.
    to automate direct search and replace you can do something along the following lines in automator
    1. get selected finder items (this will select your html files)
    2. run shell script action with input passed as arguments
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    for f in "$@"
    do
    fl=`echo "$f"`
    sed 's%home_files/photo.jpg%images/photo.jpg%g' $f > /users/$USER/.tmp.txt
    cat /users/$USER/.tmp.txt > "$fl"
    done
    rm /users/$USER/.tmp.txt</pre>

  • How do you find and replace "within selected text" in a textedit document (version 1.8, mountain lion)

    In the textedit version on Snow leopard it was possible to search and replace within a peice of selected text only i.e. not the entire file. This was a very useful feature because you could select a paragraph and replace all occurences of word1 with word2 within that paragraph only! This feature appears to be missing from the mountain lion version of textedit (version 1.8). Or can anyone tell me how to do it ... ?

    Having 46 people view a post without replying is not unusual. Some people look at a question to see if it's something they'd like to know the answer to, and then come back  when it has eventually been answered.
    I'm not sure if you need to escape forward slashes in Dreamweaver's Find and Replace dialog box, but I normally do because both JavaScript and PHP normally use forward slashes as delimiters to mark the beginning and end of the regex like this:
    var pattern = /[A-Z]{4}/; // JavaScript
    $pattern = '/[A-Z]{4}/';   // PHP
    When a forward slash appears inside the regex, you need to escape it with a backslash to avoid confusion with the closing delimiter.
    As you have worked out, a capturing group is created by wrapping part of the regex in parentheses.
    If you want to match exactly 38 characters, you can use [\S\s]{38}. That includes spaces, newline characters, symbols, everything.
    If you're trying to find everything between two tags, you can do this:
    (<\/tag_name>)([^<]+)
    The closing tag is captured as $1 and everything up to the next opening tag is captured as $2.
    Learning regular expressions is not easy. I don't claim to be an expert, but I enjoy the challenge of trying to solve them. If you're interested in regular expressions, there are several books published by O'Reilly. "Mastering Regular Expressions" is the ultimate authority, but it's a difficult read (not because it's badly written, but because of the complexity of the subject). "Regular Expressions Cookbook" is very good. There's also a new "Introducing Regular Expressions", but I haven't read it.

Maybe you are looking for

  • I want to change the date format

    Hi, I am having a date format 17.11.2005 but the system is taking it as 20051117 how to send the 17.11.2005 format to the system .It should not get converted. Regards Mave

  • Error opening printer after one print.

    I just installed Elements 12. I have been using Elements for at least 10 years. When I printed my first picture every thing went as planned, but when I tried to print the second picture I got the following, "There was an error opening your printer. P

  • What is sub routine pool in sap script? when it is used?

    hi ,          i am new to sap-abap can any one clarify my doubt .

  • How to delete SOA composite from OIM 11g

    Hello, I modified an exisiting SOA composite and deployed it as a new version. Now I have 2 versions of the same composite available in OIM. I then went and undeployed the original (version 1) from the EM interface. I also deleted it from the deploye

  • Computer fails to sleep

    When I put computer to sleep, after approximately a 2 second pause, it wakes up again.