Grep script that looks for paragraph style A followed by paragraph style B

Hello,
I am fairly new to scripting in Indesign and I have run across something I want to script that I don't know how to do. Two of the paragraph styles that are in our files are Normal and Song. I need to add an extra paragraph return between all instances of Normal followed by a Song. I tried to search the forums to see if this was already on here somewhere and if it is I didn't come across it. I would like to set it up as a grep script but if anyone has an alternative way to do this I would like to know also.
Thanks in advance

Hi,
So you could use a script.
I assume a text frame with proper story is selected and whole story is in one frame or linked frames.
myStory = app.selection[0].parentStory;
if (myStory.constructor.name !== "Story")
     alert ("Select a destination text frame, pls\rand try again");
     exit();
myNormal = app.activeDocument.paragraphStyles.item("Normal");
mySong = app.activeDocument.paragraphStyles.item("Song");
app.findTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = mySong;
mFound = myStory.findText();
len = mFound.length - 1;
if (len >= 0)
     while (len--)
     currPara = mFound[len].paragraphs[0];
          if (myStory.paragraphs.previousItem(currPara).appliedParagraphStyle == myNormal)
          currPara.insertionPoints[0].contents = "\r";
rgds

Similar Messages

  • Is there a program or setting that looks for and installs software updates?

    Is there a program or setting that looks for and installs software updates?

    System Preferences > Apps Store
    Enable all those options.

  • How can I set up a smart album that looks for keywords?

    Hi everyone,
    I'm in the middle of a rethink on my image management and am wanting to setup smart albums that will search for and display images that have a certain keyword. When I create a new smart album to do this, I'm only given the ability to choose to search for rating and calendar criteria; the keywords and import session options are greyed out. My images have keywords assigned, so where do I go from here?
    Thanks,
    Andrew

    OK, a step forward. It seems that if I create a smart album it will only look for keywords in the project that it is contained in.
    Perhaps someone can help me then: I keep a collection of albums for each person that is featured in a photograph. These albums are stored outside of the projects that the images are stored in so I can have a collection of images that show person X from all the different shoots.
    What I want to do now is keyword each image with the person's name (as a keyword) and then have a Smart album that will pick out all of their photos from my entire library, not just a certain project. How can I do this?

  • Looking for a procedure to follow when database is brought down

    I have a bi-directional Streams configuration (local capture on both ends).
    Could someone either point me to the right place in the documentation, or outline for me the best course of action to follow in the event that one of the database servers either terminates on its own or needs to be brought down. Thank-you.

    Thanks. We took one of the databases down for an hour, and Streams resynched seamlessly. I am just wondering, though. There must be some limit to how much new data can be added to one database while the other one is down (after which Streams will have a hard time resynching and we would be better off just doing an export/import to reload the second database from the first). Can you provide any guidance on this?

  • How can I autorun a script that will process an XML file on open?

    I am using Frame 11. I have a registered script that looks for event notification Constants.FA_Note_PostOpenXML. When this event fires, the script is supposed to examine the root element (so I only edit appropriate XML files), then make some edits to the file. Specifically, I want to be able to delete empty pages, remove room for side heads, and fix table formatting (such as left indent, which I can't directly access, apparently, in the EDD or R/W rules). The snippet of code that starts doing the work follows:
    Notification(Constants.FA_Note_PostOpenXML,true);
    function Notify(note, object, sparam, iparam) {
        switch (note) {
            case Constants.FA_Note_PostOpenXML:
                doTheWork();
                break;
    function doTheWork() {
        var doc, flow, root, elemName, mPageAttrib, topicElem, topicElemName, allAttribs;
        doc = app.ActiveDoc;
        flow = doc.MainFlowInDoc;
        root = flow.HighestLevelElement; // will always get something even if unstructured document
        while(root.ObjectValid()) { //only do something for structured docs
            elemName = getElementName(root);
            ...more code to do stuff....
    I then check the root element name, and if it matches, I make some changes. This code works fine when run manually. But, when run as a registered script, the app.ActiveDoc object is invalid, and there is no structure to edit. (I added debug line if(!doc.ObjectValid()){alert("not valid");}, which is not included above.) It appears that the Constants.FA_Note_PostOpenXML event fires as soon as the XML file is opened, but BEFORE Frame actually reads it.
    Does anyone have any recommendations on how to work around this? Is there another event I could use instead of Constants.FA_Note_PostOpenXML? Is there any other way to automatically manipulate an XML file when it loads?
    Thanks in advance

    The Notify event receives four parameters: note, object, sparam, and iparam. For the event you are using, object should be the document object of the FrameMaker document being opened. So, you should be able to use this:
    doTheWork(object);
    Make sure you update your doTheWork function to receive the Doc object:
    function doTheWork(doc) {
        var flow, root, elemName, mPageAttrib, topicElem, topicElemName, allAttribs;
        flow = doc.MainFlowInDoc;
        root = flow.HighestLevelElement; // will always get something even if unstructured document
        while(root.ObjectValid()) { //only do something for structured docs
            elemName = getElementName(root);
            ...more code to do stuff....
    -Rick

  • Looking for a Mail utility/script to remove older newsletters

    I subscribe to several newsletters from various companies (airlines, hotels, etc) and I'm looking for a utility/script that looks at incoming mail and zaps/displays older mailings since the new message supersedes the older ones. For instance, weekly discount offers come in and I want the previous ones from the same company to be automatically deleted. A confirmation window displaying the candidate messages to be deleted would be a nice feature.
    Does anybody know of such a utility?
    TIA

    well, to catch an email you have to add the email address from the sender or distinctive text, so for simplification purposes you may have to create a rule for each newletter, rather than one rule with lots of text in that field. plus if you create one rule for each, then it is easier to troubleshoot if one newsletter does not get deleted in the way you have specified it.
    glad i could help

  • Look for specific message in iMessage

    Hi!
    Im looking to get a script going that looks in the background for a message to arrive, and when it does it should delete a file or program.
    I've made some scripts that sends messages, but not worked with receiving.
    The script should look for a text being received from a certain contact and see if it contains a certain text.
    If both is correct, then execute the row that deletes the file.
    I tried to see if i could get the most fundamental working, but quickly failed.
    tell application "Messages"
      if lastmessage is "1234123" then
      display dialog "Start "
      end if
    end tell
    Althou "lastmessage" was not a variable.
    The text in the message can be predefined and the program/file that should be deleted can also be predefined.
    OS X 10.10.1
    Any ideas?
    Thanks!

    Not exactly.  The form is located in a read only dedicated server accessible by local users from within the companie.  Althought we urge our user to use the form from our servers by creating a Shortcut on their local desktop pointing to the original file, some of them less familiar with computers have tendencies to use a COPY of the original file instead of a SHORTCUT.  The problem with this is they do not benefit from the latest version of the form as I modify it from time to time on the server.  So when they contact me with any problem or bug they encounter, the first thing I do is check the value of a hidden text field I placed in the bottom corner named "VERSION" that hold the version number I change every time I make a new release to see if they used an obsolete version.
    What I imagined is the following.  From now on, I would place a script at doc open that does the following:
    var myVersion = this.getField("VERSION").value;
    var latestVersion = Something to check the value of the field named "VERSION" in the form located on the server;
    if (myVersion != latestVersion){
         app.alert("obsolete..blah, blah, blah");
    Maybe there is a better approach to what is basically a version checker at doc open.  Users will be using Reader and I have access to users local machines and folders.

  • Script that implements a ripple edit?

    Hi There,
    I realize that AE is not an editor, but is there a way to script a ripple edit for all layers other than the one being adjusted?  For example, let's say I have a video footage layer that has a start time somewhere in the middle of a 8 second comp, and it has a duration of only 1 second--a placeholder video.  Other layers surround this placeholder video with graphical overalys, animations, effects, etc.  Now, I want to swap the 1 second video for an 5 second video.  Is there any way via scripting to shift the layers so that they maintain the same temporal relationship to each other in the timeline?  I think what my question boils down to is if there is a script that allows for a ripple edit to occur after a video layer has been swapped for another?
    I took a look at Jeff Almosol's rdShifter and it seems to do a good job of shifting around layers' in and out points.  Is that the only thing out there for shifting layers?
    Thanks for your time and help! 
    Best,
    Laz

    I suppose the problem is - what is animated and what is not animated in the other layers and how do you automate how those keyframes are treated. Also how would the comp length and in/out points be affected by the swap.  Also if your new clip was 5 times longer - would the other layers scale from their original inpoints or scale from an average point? (Assuming there are keyframes on them) or perhaps the keyframes would not scale.
    I think there would be a lot of variables there unless you were working with the same rule day in day out.
    Not exactly what u need - but I do minor editing in AFX so these help..
    AED_SelectHereDown - Selects all layers under the currently selected layer, to aid with basic editing and  layer sliding.Sometimes it is useful when you need to slide a large group of layers. Alt&Clicking - selects here up instead.
    AED_KillDeadSpace - Searches comp and removes any space between layers by ripple editing backwards. Useful when there are accidental gaps between edits. There is an option to ‘Preserve overlaps’. This will not slide the layers back if layer B’s start comes before layer A’s outpoint. (if you have some transition operations in place). Check out the video tutorial for more clarity on this one. Alt&Click works in the opposite layer stacking order, if you work that way.
    AED_AutoTrimmer -Set your time in frames using Shift+Click. Trims one selected layer to the time chosen(using work area). Then pushes the work area forward by the chosen time and leaves cursor in the centre. This allows you to slide a layer to find a good key point in the footage, then go again. Great for selecting clips quickly that need to be a specific duration and assembling a quick edit.

  • Can't find "Look for shared libraries" in the Sharing pane of iTunes preferences. How can I find it?

    I am trying to set up Home Sharing between my computer and my wife's. Sharing keeps disappearing from the side bar although Home Sharing is turned on for both computers. Using the Help tab it says to check the "Look for shared libraries" in the preferences/shared box. The problem is that "Look for shared libraries is not there to select. Any ideas how I can sort this out?

    I'm having a similar issue even after the "Shared Libraries" box is checked in General preferences on iTunes...
    On early verisons of iTunes i had no problem with sharing or remote access via iPad.  I really need to figure out how to get this working.

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Looking for jquery lightbox script that stretches image to fill viewport

    There are a lot of lightbox scripts out there, but most of them seem to favor static-sized images.
    I'm surprised that I haven't been able to find too many of these scripts allow for images to make maximum use of a viewport's dimensions. In other words, lightbox-style scripts that will fit the target image inside the viewport (while retaining the image's native proportions), whatever size said viewport may be.
    I can easily imagine everyone from graphic designers, to painters, to photographers jumping on such a tool. After all, there's nothing worse than looking at a 500px image on a 1920px display. It makes the work feel small, and by proxy, the work's author look small.
    Granted, for the images to not appear stretched, the native size of the image would have to be larger than needed for most visitors, but portfolio websites aren't high-traffic websites. They're solely visited by potential employers and clients, and loading time isn't much of a concern anymore with today's average home broadband speeds topping 1mb/s.
    Ideally, the script would grey-out the website, and display an image to match 95% of the viewport's X or Y resolution (whatever is smallest) while retaining the image's native proportions.
    Does anyone know where I can find such a script, preferable in jquery (since I'm already using it on my website)?

    Finally found one! -> http://www.shadowbox-js.com
    I've been testing it out, and it does exactly what I described above. It's great.

  • I blog on TypePad using Word 2007 and documents freeze when I'm looking at them in Windows explorer; why do I get the error message that Mozilla is looking for a script?

    I have now had two error messages - the first one looked for this script: Script: resource://gre/modules/XPCOMUtils.jsm:258. The second one (today) looked for Script: resource://gre/components/nsPrompter.js:68.
    I have reset my word template, also reset word registry for data and options (as per Microsoft's help pages) for both those 'fixes' there was an initial improvement, but the problem happened again after I reposted on my blog today and then went to Windows explorer to view my files. It seems to 'seize' as I select a file, so that the preview does not appear (for up to 15-20mins).
    I see on the internet using the second script as a search just now that one other has had a similar problem and one also since Mozilla 4 upgrade. My problems have also been pretty much since I upgraded.
    It happens (apart from my fixes) every time I go to look at a word document via Windows explorer. Excel files are less affected.
    One web suggestion is to clear the cache, but I am hesitant to lose all my passwords unless I have to.

    I still have the problem although I uninstalled Mozilla (clearing the cache didn't work and neither did Word diagnostics), so have ended up thinking it could be Norton (the manual update worked x1) or Windows. Today I found an answer: disable the preview pane in Windows Explorer - there's a history of problems with this view.

  • Looking for someone to script a Day Planner to a specific size and style.

    Hi,
    Looking for someone to script a year long Day Planner in Indesign CC. I've tried one or two scripts available out there but none seem to be able to accomplish what I need.
    I would envisage the rolling requirements.
    2015
    Day per page
    Set to a specific Design Style
    Fully Editable style hierarchy
    Ability to add in pages without kicking anything out
    Include Month with highlighted day on right hand page only
    Add localised public holidays
    Add another list of 'special dates'
    Fit size 148.5mm W x 210mm H (would be great to have it scaleable but not essential)
    All/any help appreciated. Here's a screen shot of the desired result.

    Hi Jarek,
    Thanks for the response!
    The script needs to create the pages in an Indesign Doc.
    One the pages are created we would be adding in custom pages at beginning and at other periodic stages in the document.
    Let me know if there's anything else you need
    Mark

  • Looking for a script that get images' urls from a website

    Hi,
    I have a website where users can insert theirs hotel informations.
    Most of them do not insert photos, I guess because the procedure is quite long and difficoult for the average user's skills.
    I'm looking for a script that take as input the url of the website and give as output the urls of the images of the site, so the user can decide which to upload on his tab.
    Someone can help me?

    La_Salamandra wrote:
    I have a website where users can insert theirs hotel informations.
    Most of them do not insert photos, I guess because the procedure is quite long and difficoult for the average user's skills.
    I'm looking for a script that take as input the url of the website and give as output the urls of the images of the site, so the user can decide which to upload on his tab.
    Someone can help me?
    You have to improve your design. Even if you can find the Coldfusion code, your design will still fall short in 2 ways.
    First, it is unreliable, because you're depending on some arbitrary site to be available and up to speed. Secondly, it is aesthetically wrong to be collecting pictures, especially large numbers of them, dynamically from someone else's site.  Think of their copyright and bandwidth.
    Fortunately, there are simple solutions. First, identify, by eye, the web pages containing the pictures you're interested in. Ask for permission from the owner.
    You could indeed use Coldfusion's cfhttp or any other script to download the JPGs, PNGs, and so on. But then, why waste your time re-inventing the wheel? It is infinitely better to use a web crawler !
    With most crawlers, you only have to supply the URL of the site, and the file extensions it has to grab (in your case, jpg, png, bmp, and so on).
    One click on the button, and you have them reeling in. Automatically. Some crawlers are considerate enough to enable you to adjust the download bandwidth. (We can learn from a million years evolution wisdom. The vampire bat is known to inject a painkiller before sucking!).
    Now that you've downloaded the images to your site, the links you display to your users are all yours. You may choose to resize some of the images, display them as you wish, and the issues of reliability and bandwidth are now up to you.

  • Set by script the tag and/or the class of a paragraph style for HTML / EPUB export?

    Is it possible to set by script the tag and/or the class of a paragraph style for HTML / EPUB export?

    I found a way
    tell application "Adobe InDesign CS6"
      tell document 1
      tell paragraph style 2
      --get count of style export tag map
      tell style export tag map 1 -- HTML  , 2 = PDF
      --get export class
      --get export tag
      set export tag to "H1"
      set export class to "blue"
      end tell
      end tell
      end tell
    end tell
    and its works
    but thanks for help to use the class "style export tag map"

Maybe you are looking for

  • Iweb  FTP,Printing probems with Iweb .Pages to Web

    I feel like writing Steve Jobs.Problems -I had Iweb 08 , upgraded to Iweb09 because of the press how FTP was solved. I cannot upload to my server. I have spent hours talking to Apple Care reps.I have tried several FTP softwares other than Iweb.One re

  • Photos App iOS 7????

    How do you get the top and bottom menus to go away in photo app. I take a lot of pictures in landscape mode an when I go to photos and view them they are covered on top and bottoms by the menus. Before iOS7 you could tap the screen to bring up the me

  • Video rendering extreemly slow or just halts

    Being playing with video a bit since I bought a Sony RX100 III.  Other than the well known problem with Dolby audio I find that rendering of video clips in Photoshop CC is very hit or miss.  Sometimes the clip renders (very slowly if many adjustments

  • Snow leopard 10.6

    Hello I just got my new iphone 5, but now i only runs on Itunes 10.7. To complete the upgrade my Imac has to be 10.6.8 My Imac is currently 10.5.8 and i want to ugrade it to 10.6 (snow leopard) But i can't find it on app store or anywere else? Does s

  • A2A integration using XI

    All, I am trying to create a simple application to application proof of concept to show the capabilities of SAP XI , both source and target systems as NON SAP systems.Can some one guide on what kind of applications can i use. If i am using a 2 J2EE a