Can you search / replace by paragraph order?

I use to identify what story to do this on style of script.

Once I found this label, I want that javascript to find / replace the style by order the paragraph.  When I import real text, I get a first style expected (using the following Style is me well marginal).  The script I'm writing would be search in history "Paragraph 3" (for example, in appliedParagraphStyle) and replace it with a different style applied.

The question I have is the research appliedParagraphStyle of the order in which it appears.

Does anyone do this?  Thank you very much.

Your interpretation is correct. JS begins the first paragraph with a "0" index.

So the steps are:

1. find your labeled textframe. > Instead of the label property, you can also use 'name' by registering a name in the layers panel.

2 save your paragraphs and directly apply a paragraph style (no need to a GREP) > in my example I go the long way, but you could combine some lines.

3. identify the para quote and apply quotes. I give you here a simple example. My example fails, if already are in quotes. In this case, the grep to be built differently.

And one last comment: why do you need 2 frames of related texts? Why not include the title with the functionality of the columns covering?

var curDoc = app.activeDocument;
var allTFrames = curDoc.textFrames;

for (var i = 0; i < allTFrames.length; i++) {
  var tFrame = allTFrames[i];
  if (tFrame.label == "format 1") {
    var pStory = tFrame.parentStory;
    var allParas = pStory.paragraphs;
    var first = allParas[0];
    var sec = allParas[1];
    sec.appliedParagraphStyle = "author";
    var third = allParas[2];
    var fifth = allParas[4];
    fifth.appliedParagraphStyle = "quote";
    var fifthContents = fifth.contents;
    var tempString = fifthContents.replace(/(.+)/,"\"$1\"");
    fifth.contents = tempString;
  }
}

Tags: InDesign

Similar Questions

  • In editing in the browser can create you new text boxes and images or can you only replace pre-existing text/images?

    Editing in the browser can you create new areas of text and images in your muse site? Or can you only replace pre-existing text/images?

    You can only replace the existing content, do not change the structure of the page. See the respective help sections.

    Mylenium

  • How can I search - replace in master pages only?

    Hello world

    How can I search - replace in master pages only?

    for example:

    I want to change in 2013-2014, but only in master pages.

    in master pages for all of the open files.

    How can I do?

    Teetan

    Hi Teetan,

    To set a goal is more of halfway to creation script.

    Check this box:

    app.doScript('main()', ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "grow numbers on masters");
    function main() {
      catchOption = app.findChangeGrepOptions.includeMasterPages;
      app.findChangeGrepOptions.includeMasterPages = true;
      app.findGrepPreferences = changeGrepPreferences = null;
      app.findGrepPreferences.findWhat = "\\b\\d+\\b";
    
    var
      mTarget = app.documents.everyItem().masterSpreads.everyItem().textFrames.everyItem(),
      mFound = mTarget.findGrep(),
      mConFound = [],
      len = mFound.length;
    
      if (len && mFound[0].constructor.name == "Array")
           while (len-->0)
                mConFound = mConFound.concat(mFound[len]);
    
      len = mConFound.length;
      while (len-->0) {
           mConFound[len].contents = String(Number(mConFound[len].contents) + 1);
      }
      app.findChangeGrepOptions.includeMasterPages = catchOption;
    }
    

    Jarek

  • Search &amp; replace in paragraph 1 paragraph Format 2 Format

    Hi all

    In the document that I received which has two tags to paragraph, a legend of Figure 1 and another legend of Figure 2.

    Some are assigned Figure Caption 2 and some figure allocated Figure Caption 1.

    How do I find all the Figure 2 legend and convert them to Figure Caption 1?

    Find, there a paragraph tag: (picture below), but in the replace box, I have no option.

    Thank you.

    The first Ting you need to do is to load the Clipboard with the "legend of Figure 2" paratag.

    This is done by placing the cursor anywhere in a paragraph that is labeled with the "legend of Figure 2". And then on the Edit menu > copy special > paragraph Format to load the Clipboard.

    Now, using the Find dialog, searching for the "legend of Figure 1" (all the text, else it stops at any paratag legend for Figure). In the box replace, use the option 'Sticking' to apply the desired paratag.

  • accidentally, I buy the windows version of adobe acrobat DC instead of the mac version. I have only a mac computer. can you please cancel my purchase and replace it with the version of windows with a mac version.  the order number is AD006058877NL. Rgds,

    I accidentally buy the windows version of adobe acrobat DC instead of the mac version I only a mac computer can you please cancel my purchase and replace it with the version of windows with a mac version.  the order number is AD006058877NL. Rgds, jan van montfort + 31681471049. [email protected]

    Hi Jan,

    I understand your concern, please see this doc on this subject: return, cancel or change an Adobe order

    Kind regards

    Rahul

  • How can I make a long list of search - replace only the master

    Hello world

    I had this script:

    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text on master blocks spreads are not affected.
    If you want to unblock, please add something like this:

    Unlock all elements of each document page on is spreading and Captain spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "\\b20\\d+\\b";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = String (Number(flattenedFoundArray[n].contents) + 1);
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;

    //---------------------------------------------------------------------------------------- -------------------------------

    made by Uwe

    I change in this, to make a multi elements of search - replace only the master

    //==============================================================================

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "USA";

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "CHINA";
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //---------------------------------------------------------------------------------------- -------------------------------

    myDocuments var = app.documents.everyItem ();
    var myLayers = myDocuments.layers.everyItem ();

    Locked text spreads masters frameworks are not affected.
    If you want to unblock, please add something like this:

    Unlock all items page of each document of spreads and master spreads (optional):
    myDocuments.pageItems.everyItem (.locked = false);

    var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem ().pageItems.everyItem ();

    Unlock the layers (optional)
    myLayers.locked = false;

    Lock all elements of page level first on normal spreads
    This leaves the elements on the page on unlocked master spreads:
    myPageItemsOnNormalSpreads.locked = true;

    Now for the GREP part:
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findGrepPreferences = changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = 'Washington DC';

    Research on "all open document" level
    Which returns an array of arrays:
    var myTarget = myDocuments.findGrep ();

    Flattening of myTarget Bay:
    var flattenedFoundArray = [];

    for (var n = 0; n < myTarget.length; n ++) {}
    flattenedFoundArray = flattenedFoundArray.concat (myTarget [n]);
    };

    Change the content of the texts found in flat table:
    for (var n = flattenedFoundArray.length - 1; n > = 0; n-) {}
    flattenedFoundArray [n] .silence = "Beijing."
    };

    Unlock all objects on normal spreads:
    myPageItemsOnNormalSpreads.locked = false;

    Reset search GREP and edit the prefs:
    app.findGrepPreferences = changeGrepPreferences = null;


    //===============================================================================

    only what I can do is to repeat and repeat again

    is this another perfect solution to do?

    Thank you

    Teetan

    Try this,

    findChange("USA", "CHINA");
    findChange("Washington DC", "Beijing");
    
    function findChange (findWhat, changeContent){
        var myDocuments = app.documents.everyItem();
        var myLayers = myDocuments.layers.everyItem();
        //Locked text frames on master spreads are not touched.
        //If you want to unlock them you have to add something like this:
        //Unlock ALL page items in every document on spreads and master spreads (optional):
        myDocuments.pageItems.everyItem().locked = false;
        var myPageItemsOnNormalSpreads = myDocuments.spreads.everyItem().pageItems.everyItem();
        //Unlock the layers (optional)
        myLayers.locked = false;
        //Lock all first level page items on normal spreads
        //That leaves the page items on master spreads unlocked:
        myPageItemsOnNormalSpreads.locked = true;
        //Now for the GREP part:
        app.findChangeGrepOptions.includeMasterPages = true;
        app.findGrepPreferences = changeGrepPreferences = null;
        if(findWhat)app.findGrepPreferences.findWhat = findWhat;
        //Do the search on "all open document" level
        //That will return an array of arrays:
        var myTarget = myDocuments.findGrep();
        //Flattening the myTarget array:
        var flattenedFoundArray = [];
        for(var n=0;n=0;n--){
            if(changeContent)flattenedFoundArray[n].contents = changeContent;
            };
        //Unlock all objects on normal spreads:
        myPageItemsOnNormalSpreads.locked = false;
        //Reset GREP find and change prefs:
        app.findGrepPreferences = changeGrepPreferences = null;
    }
    

    Vandy

  • Hi apple, can you replace my iphone 6 again?

    Hi apple, can you replace my iPhone 6 again? Because my phone screen has been a little out of his cases and I think that my battery has become thicker, through my iphone still the limited apple warranty, how much it costs if repair? And or replacement for new phone?

    Thank you.

    You're not talking to Apple, this is a site for technical support to users.

    If your iPhone is still under warranty and an Apple employee determines that it is a swollen battery and not accidental damage, they will replace your iPhone with an identical model to the one you have now.

  • Yahoo has become my default search engine. It used to be google; I want google as my default search engine. Can you help me?

    Google was the default search engine in my configuration of FireFox. Now it's Yahoo. I would like to go back to google. Can you tell me how he go back to google? If so, thank you.

    This has happened

    Each time Firefox opened

    Is two or three days ago.

    In the address bar, type Subject: config and press ENTER. The subject: config "This might void your warranty!" warning page may appear. Click on that I'll be careful, I promise! to continue on the subject: config page.
    Locate keyword.urlpreference.
    Right-click on it and select reset.

    More information: Search the Web from the address bar

  • When you search our office location, 700 N. Pearl Street Dallas, Apple cards removes the PIN in a location 12 miles away.  How can this be corrected?

    When you search our office location, 700 N. Pearl Street Dallas, Apple cards removes the PIN in a location 12 miles away.  How can this be corrected?

    In the lower-right corner, click on the 'i' and select report a problem.

    It takes time, but the problem should be solved after as they verify the information.

  • try to sync iRiver, using the version of wmp 11 and no progress after 5%... impossible to remove version 11 to replace it with an older version... can you help me

    try to sync iRiver, using the version of wmp 11 and no progress after 5%... impossible to remove version 11 to replace it with an older version... can you help me

    Hi florane

    Have you been able to sync with WMP11 before? This problem only started recently?

    Try these steps and check:

    1 check out the iRiver firmware updates site - they have made updates to H10 for example when WMP11 is out:

    http://www.iriver.com/HTML/support/download/sudw_list.asp?searchProductIdx=73

    2. also delete sync in WMP relationship - plug in the appliance, if it is set to auto-sync: plug it in, go to synchronize, click on the small arrow below, and then choose the iRiver and the 'end sync partnership.

    3. then go to the Control Panel, Device Manager, see if the camera is there, and then uninstall it. Disconnect and reconnect the iRiver, which should refresh the device and restart WMP to see if it works better.

     

    4 also a device for synchronization in the Windows installation Media Player

    After back and let us know if it helped to solve your problem.

    Thank you and best regards,

    R uma - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • My hard drive crashed and he was replaced. However, Windows 7 Premium replaced instead of Windows Pro. I now need a product code for windows 7 Premium. Can you help me, please?

    Original title: product key

    My hard drive crashed and he was replaced. However, Windows 7 Premium replaced instead of Windows Pro. I now need a product code for windows 7 Premium. Can you help me, please?

    See instructions to reinstall the correct version:

    How to: What are my options for Windows 7 reinstall media?

  • The streaming videos on Windows Media Player error "your media usage rights were corrupted or are no longer valid. This can happen if you have replaced hardware components in your computer.

    I'm trying to videos from 3 completely different sites.

    The last post I got Windows Media player was

    "Your media usage rights were corrupted or are no longer valid. This can happen if you have replaced hardware components in your computer. »

    I replaced WITHOUT hardware on my computer, and last week, I could listen no problem at all!

    How to get corrupted my media usage rights and how to remedy the situation?

    I'm not a complete dummy, but sometimes I feel like one. :(

    Hello

    This problem can occur if the media rights (DRM) a folder is corrupted. We need to reset Windows Media DRM in delete/rename all the files in the Windows Media DRM folder. Note that the Windows Media DRM folder is a hidden system folder.

    Check out the links and follow the suggestions that are marked as an answer:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-Winapps/getting-error-messageyour-media-usage-rights-have/54bfacbb-C104-4c22-800F-f293d18d94c2

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-pictures/constantly-getting-this-message-your-media-usage/840c560d-04aa-4ae2-aed0-59022cfdef04

    Please let us know if the problem still persists.

  • can you replace the motherboard of dv7 1232nr in the new motherboard supporting the i3, i5 or i7?

    Hello all can help me please

    I have a laptop dv7 1232nr and I have questions on the processor because it is only a dual core im thinking and the replacement of the motherboard that supports anygeneration of i3, i5, or i7 from intel

    is this possible? also, including the video card?

    If there is can you please help me...

    Thank you

    Hello

    My suggestion: buy a new machine because add them, cost more than buying a new machine itself and the result of may will not be big, UNLESS you are having another machine and use this machine for experimentation.

    Kind regards.

  • Hello! I can't subscribe to creatively Cloud for photographers. When you subscribe to gives an error when you pay with the card: "order processing error occurred for more information, please contact the Customer Service by phone 8 800 333 36 63."

    Hello! I can't subscribe to creatively Cloud for photographers. When you subscribe to gives an error when you pay with the card: "order processing error occurred for more information, please contact the Customer Service by phone 8 800 333 36 63, when making a payment via PayPal: PAYMENT_CPG_SETTLE_FAILED. How to order?

    Contact adobe during the time pst support by clicking here and, when available, click on "still need help," http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • I got an old macbook pro version osx.6.8 and that you want a version of photoshop that I can use on it, but after searching the Internet, I am completely confused. Can you help me?

    I got an old macbook pro version osx.6.8 and that you want a version of photoshop that I can use on it, but after searching the Internet, I am completely confused. Can you help me?

    It's so old, that I doubt you'll have something to work on it which currently does not work.

    PS must be prior to version 3.

    Configuration of Photoshop

Maybe you are looking for