Locate and replace the last paragraph style

With .js or grep, I want to change the style of the last paragraph ball against one with more space after, there are a lot of them in one story mixed with other styles.

Change this:

  • B. blarrblarr (bullet style)
  • B. b. b. b. (bullet style)
  • B. b. change it (bullet style)

To do this:

  • B. blarrblarr (bullet style)
  • B. b. b. b. (bullet style)
  • B. b. change this (last bullet style)

Is this possible? If anyone can help would be great!

Thank you very much!

I think that this JavaScript does the job. You may need to change the style names to match yours. In addition, it assumes that the styles are not grouped in a folder.

//DESCRIPTION: Fix last bullet paragraphs

(function() {
     if (app.documents.length > 0) {
          findFixLastBullets(app.documents[0]);
     }
     function findFixLastBullets(aDoc) {
          setupFindText();
          app.findTextPreferences.appliedParagraphStyle =  "Bullet";
          var myFinds = aDoc.findText();
          for (var j = myFinds.length - 1; j >= 0; j--) {
              var lastPara = myFinds[j].paragraphs[-1];
              // if next para already BulletLast do nothing
              var nextPara = lastPara.insertionPoints[-1].paragraphs[0];
              if (nextPara.appliedParagraphStyle.name == "BulletLast") continue;
              lastPara.appliedParagraphStyle = "BulletLast";
          }
     }
     function setupFindText(find, change, wholeWd, caseSense, foots, hidLayers, lockedLayers, lockedStories, masters) {
     app.findTextPreferences = null;
     app.changeTextPreferences = null;
     try { app.findTextPreferences.findWhat = find } catch(e) {};
     try {app.changeTextPreferences.changeTo = change } catch(e) {};
     app.findChangeTextOptions.properties = {
          caseSensitive:(caseSense == null ? false : caseSense),
          wholeWord:(wholeWd == null ? false : wholeWd),
          includeFootnotes:(foots == null ? false : foots),
          includeHiddenLayers:(hidLayers == null ? false : hidLayers),
          includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
          includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
          includeMasterPages:(masters == null ? false : masters)
     }
} // end setupFindText

}())

Note the small touch that if the next paragraph is already BulletLast, it ignores who found the text. This allows you to run the script more than once if you add more text.

Dave

Tags: InDesign

Similar Questions

  • Remove the imported chips and replace them by paragraph Style

    I imported a large number of documents to PDF and I need to remove the text format for the numbering of lettering and balls and replace them with paragraph styles. I find it difficult to arrive at a text or grep search and replace for it.

    So far I managed to assign bullets paragraph style, but I can't seem to remove the imported point. This is my poor attempt a search and replace. I guess it's possible to do it also for lettering and numbering?

    Screen Shot 2016-04-20 at 15.06.36.png

    and that's what it looks like after the change with the ball remaining.

    Screen Shot 2016-04-20 at 15.13.17.png

    Good question! Can anyone chime in with the 1-step process, but it is darn fast than two, especially if you save the first query:

    • Search: Bullet tab
    • Change of: Para style balls
    • All changes

    • Click on the trash can to delete the paragraph style
    • All changes

    Fact.

    With GREP, you might find one or several characters followed in a tab at the beginning of a paragraph (^. + ^ t) to locate any list, but you would need to set the style of bullets to bullets, the style of numbering of numbers and the AlphaNumbering style to the letters, so I don't see a benefit.

  • Locate and replace the breakers InDesign file

    I'm working on a file and whenever I do a search and replace, it crashes. I ran recently Adobe updater and when I did, the application gave an error that "Scotch rules" have been used on the last saved version and it has not been loaded on my system. As I built this file on my system, I knew I had rules of Scotch. I went in my extensions Manager and helped him. This did not help the fracas. It crashes with this load and it has not loaded.

    I also trashed my preferences in InDesign using the cmd + opt + Ctrl-Shift, as well as by the hand towards records. Nothing works

    Any ideas?

    Thanks in advance!

    Peter Spier It turns out that the screen resolution is the issue. A friend mentioned that Illustrator has problems with greater than a certain number of screen resolutions. I had recently changed my screen resolution and forgotten. So, Yes, it is preferable to keep the resolution of the screen down in order to keep the Adobe products to act weird. Mine is of the order of 1400 now.

    Thanks for your suggestions.

  • Locate and replace the error style para

    Hi experts,

    How can I make this script correct?

        app.findGrepPreferences = app.changeGrepPreferences = null;
        app.findGrepPreferences.findWhat = "^\\s$";
        app.findGrepPreferences.appliedParagraphStyle = "Line_0.5";
        app.changeGrepPreferences.appliedParagraphStyle = "Line_0.5 Color";
        app.selection[0].changeGrep();
        app.findGrepPreferences = app.changeGrepPreferences = null;   
    

    Thank you

    Respect of

    John

    Hi Johnwhite,

    I changed the above code. In the snapshot shown the definition contains with a ParagrphStyleGroup.

    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^\\s$";
    app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Table Line").paragraphStyles.item("Line_0.5");
    app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Table Line").paragraphStyles.item("Line_0.5 Color");
    app.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    

    THX,

    csm_phil

  • Is there a program to locate and replace the missing files in Win XP Pro 64 and the dll?

    I am running Win XP Pro 64 SP 2, on xfx 680i LT MoBo, Intel Duo Core 3 GHz. My computer is seen adapts to any time and stutters a lot, and sometimes I confuse it so it sits and wonders every day. When I see autorun (Sys Internals) I find several file not found entries. The same thing happens with Malware Bytes and HiJack This. Is there a program that will search for files or corrupt links and repair; missing it works? Thank you all. Merry Christmas.

    Thank you all for your responses pending. I want to especially thank Jose Ibara for in-depth answers. He is now coming along and no new response is necessary (I hope, or this thing dies!). Once again thank you.

  • WTH?  I have a gap in the text that I can't fill.  There is no hidden formatting that I can find, and I apply a paragraph style to text.

    WTH?  I have a gap in the text that I can't fill.  There is no hidden formatting that I can find, and I apply a paragraph style to text.

    I'm not well-versed in indesign, but what I've discovered, is that the box around the page number on the master was wrapping text, which was originally my text to break around her at the center bottom of the pages.  Problem solved, and amiellemiel is right.

  • Replace the last comma by "and".

    Hi all

    Please let me know is there a simple way to replace the last comma in as string with 'and '.

    for example: 1. abc, xyz, wuv must be returned to abc, xyz and wuv

    2 abc, wuv must be returned, abc and wuv

    3 abc and pqr, cuq, wuv must be returned to abc and pqr, cuq wuv

    DB version: 11.2.0.3

    Thank you

    DS

    Hello

    Here; s in one direction:

    REGEXP_REPLACE (str

    , ',([^,]*)$'

    , 'and \1 '.

    )

  • How clear the text paragraph styles imported from the word?

    I am trying to create a user manual and I use a model that has its own set up paragraph styles.

    I use InDesign CS6 because I use the PDF2ID of Markzware plugin that I bought for this version. I used it to bring in the instructions of the users who have made their work in Word and saved in PDF format.

    I just want to take their work and re - format to match the styles of paragraphs in the model. But when I select the text and choose a new paragraph style, it does not change.

    I tried to use the button 'Clear the replacements' but nothing happens.

    I found a site that offers to use keyboard shortcuts to clear the formatting, but they no longer work.

    What Miss me?

    PDF don't know anything about styles. The plugin could have done a few "intelligently" all styles, based on the formatting, but I don't know if he is capable of that because I've never used.

    Hold Shift + Alt\Opt click a paragraph style should apply this style and remove character styles as well as local formatting overrides.

  • Why can't define paragraph ball in the standard paragraph style?

    I want to configure my standard paragraph style so that I can quickly apply the individual paragraphs balls - using MY favorite dashes - without having to create a new style to the paragraphs of the ball. I tried to change the settings of the standard paragraph, with no document open style, but he doesn't seem to accept my choice of dashes. First of all, I selected bullets and put a dash, but then the default paragraph with bullets. When I pass the ball setting back to "none" the only thing he keeps is the last setting that I chose for the tabs. (At the same time, which changes the default tab for all paragraphs setting.) But when I create a new doct and start a paragraph of the ball, the hyphens by default always a.25 /-.25 and any tab setting LOWER a.25 results in the updated first line indented for the tab setting, but the rest of the paragraph indented a.25. There seems to be no way to change default indentation for bullets without creating a new paragraph style. And usually I'm fine with that. But I thought that I would have a default Quick using the standard paragraph style. Am I missing something or is it just not possible?

    Here is a Visual/verbal screenshot to help explain:

    InDesign-Bullet-Problem.png

    Let's see if I understand differently from others. You want to apply bullets manually from time to time without having to select a new style, you would do this by pressing the button bulleted list in the Control Panel, and you want the settings for tabs and indents, other than the default. Is this correct?

    Far as I can tell there is no way to do it. You cannot configure the settings for the chips unless the text cursor is active or if you set a style, there is no way to set up the new default values. You don't want to not set parameters whenever you need a ball, then either you type the balls by hand, tab and insert a hyphen character here, which is actually a lot more work, or you go ahead and set up the style. You can access the list of style in the menu drop-down control panel, or you can add a keyboard shortcut to give you quick access, or press Ctrl (Cmd on Mac) + entry for quick access to apply and start typing the name of the style (almost as fast as a keyboard shortcut).

  • What has replaced the last good configuration in windows 8

    Hello

    I hear 2 weeks there is a member of the microsoft community this last good configuration does not exist anymore in windows safe mode 8.

    is this true? If Yes, what feature has replaced the last good configuration?

    Thank you

    Joha

    You can access all the options of recovery like this:

    1. Click the Power Options icon, and then hold down the SHIFT key while you click the Restart option. Keep now shift until the screen shows it restarts.
    2. On the first screen that appears, select troubleshooting, and then select Advanced Options. Finally, choose the boot settings and click Restart.
    3. On the next screen, you will see things like Safe Mode and service options which would be "last well known."
  • Problem affecting the existing paragraph style

    Hi all!

    I have searched all morning and can't find a lot of good documentation on the use of existing scripts paragraph styles to HAVE. I know that you can build a live, but more specifically, I want to add in the tabs and don't see this as an option to add paragraph styles in one of the refs to javascript.

    I do an "export log" that captures the version, date, time, artist name/layers assigned to help our team of quality control. My problem is that any new text added to the box ignores existing paragraph styles, and I do not see so he can apply what I have in the file.

    I can find the style, so I don't know it exists, and I can also draw the text box, so I think that these paths are correct and working, it's just the applyTo seemingly does not. Here is my code below:

    //get the textBox with the sign off content
    exportLogText = docRef.textFrames.getByName("RT_Signoff");
    //add the sign off text
    exportLogText.contents += "v. " + versionLetter + "\t" + theDate + "\t" + timeStamp + "\tExport by: " + username + "\tLayers: " + layersExported;
    exportLogText.contents += "\r"
    //identify the "Export_Log" paragraph style that already exists in the AI doc
    var paraStyle = docRef.paragraphStyles.getByName("Export_Log");
    for (ps = 0; ps < exportLogText.paragraphs.length; ps++){
        paraStyle.applyTo(exportLogText.paragraphs[ps], true);
    }
    redraw();
    
    

    Once it hits the applyTo line, the script stops. I found similar posts claiming this code should work, so I don't know what I'm missing! Any help is appreciated.

    I found a similar code here:a paragraph style for blocks of text in the document

    It's really a matter of aesthetics, but I can't stand the text to look like this:

    issue1.PNG

    When he could look like this!

    issue2.PNG

    Looks like it was a problem with my file which was causing the anomaly, not the script. Things seem to be working now! Thanks for the input guys!

  • Replace the last occurrence of a word in a string

    Hello

    I need to replace the last occurrence of a word in the string. Example of form:

    "I like fruits and vegetables as" need to replace the last occurrence of 'like' that is just before the vegetables and not 'as' before the fruit.

    Something like that!

    SELECT
        REGEXP_REPLACE('I like fruits and also like vegetables','like','hate',1,2) data_col
    FROM dual;
    
  • Remove based on the substituted paragraph style attributes

    Is there a way to clear the attributes that you put in a "based on" paragraph style, on the part of start by resetting to the base?

    For example:

    • 1 a paragraph style track set to + 10.
    • You create 2 of paragraph 1-based Style and made several substitutions, including change tracking to + 5.
    • Now you realize you want the two styles have the same follow-up and you want to experiment with this setting.

    How can you erase what has been entered in the Style 2, so that any changes made to the Style 1 applies to the 2 Style once again? I realize that it is possible with character styles, but after scouring the net, I think that this should not be possible with paragraph styles.

    Am I wrong? If this is not the case, why it should not be possible?

    Thank you.

    Go to the 2 paragraph style definition and reset the traking to the same value as the base style. It becomes as well as watt do you the basic style. Only the attributes that are different are locked.

  • I have different bookmarks I want to keep on each computer, synchronization will delete the bookmarks on a single computer and replace the bookmarks from another computer in their place

    I have not yet used sync, but I sense it's going to be a problem if I do. I have different bookmarks I want to keep it on each computer. Sync will delete the bookmarks on a single computer and replace the bookmarks from another computer in their place? So I think that will erase the bookmarks on the second computer you configured to synchronize. Is there a way to merge bookmarks on every computer in the library of a bookmark that contains all bookmarks on both computers, so I'm not all bookmarks in sync?

    Just to be clear, this is something that we have commented several times in the forum, Firefox Sync adds everything that is already in the device for the account and pushes this info for the rest of the devices.

    So if you have 2 computers with data X and the other with the data from there, once you set up synchronization in both computers you will have X + Y at the same time.

    I hope that clarifies the doubts...

  • Satellite A30 921: how to remove and replace the memory?

    Hi, can someone help me how to remove and replace the memory of satellite A30 921. and also, please give a detailed instruction.

    Thank you in advance.

    Hello

    There is not much to explain. On the low side in the Middle it is placed to cover memory (fixed with two screws). Remove the cover and you will see 2 slots there. I put t know how much memory you here but like Stefan says you can use max 2 GB of RAM (2 x 1024Mo PC2700 - PA3313U-1M1G). How to remove the memory modules, which you can see on http://www.hardwaresecrets.com/article/189/5

    Good bye

Maybe you are looking for