Sorting paragraph, apply style then next and (maybe) placing images...

Hi everybody,
I have to set a layout on several pages for a magazine, arranging pictures along with some text related.
I have a text file of this kind:
Text a/1 (should apply Heading style)
Text b/1 (should apply Bodytext style)
Text a/2 (should apply Heading style)
Text b/2 (should apply Bodytext style)
+ Photo
Text a/3 (should apply Heading style)
Text b/3 (should apply Bodytext style)
+ Photo
Text a/1 (should apply Heading style)
Text b/4 (should apply Bodytext style)
etc...
I wish to sort the paragraphs, keep note of those where an image is needed, strip them out into a new frame on the pasteboard with the picture reference and apply to the main text column the styles in order.
Let me explain better with some pictures...
a) b) c)
d) final)
Is it possible, in your opinion?
Thanks,
Guido

Okay, I created a small file with the text
title
subtitle
body
body
body
and the title style applied to the first line. I then ran your new 
script, which I had to fix up a little because it got slightly messed up
in the translation to e-mail text. And now it works!
Let's see if I can get it into AppleScript...
First of all, hmm, it's interesting that the script text in the forum
has
var style_name = "h1"
with "h1" red, while the e-mail version I received has
var style_name = "title"
Maybe you changed your message after posting it? No matter, I carry on
and here's the result:
tell application "Adobe InDesign CS4"
   tell document 1
     set theStyle to paragraph style "1.Bold Head 1"
     set applied paragraph style of paragraph 1 of selection to theStyle
     repeat with i from 2 to count of paragraphs of selection
       tell selection
         set applied paragraph style of paragraph i to ¬
           next style of applied paragraph style of paragraph (i - 1)
       end tell
     end repeat
   end tell
end tell
This works the same as yours with the "title" style, but let's go
one more:
tell application "Adobe InDesign CS4"
   tell document 1
     set theStyle to paragraph style "1.Bold Head 1"
     set applied paragraph style of paragraph 1 of selection to theStyle
     repeat with i from 2 to count of paragraphs of selection
       tell selection
         set applied paragraph style of paragraph i to ¬
           next style of applied paragraph style of paragraph (i - 1)
       end tell
     end repeat
   end tell
end tell
This works for any style, so I only need one script! Option-n is 
available as a QuicKeys trigger and I use option for other paragraph 
style assignments, so I'll assign it to that. Thanks!
Roy

Similar Messages

  • Applying a shortcut to "Apply "style" then next style"

    In CS2, is there a way to apply a keyboard shortcut to the "Apply 'style name' then next style" command in the paragraph styles menu.
    thanks
    jon

    Gerald,
    I retrieved the script for CS2 which I've copied below. I changed the name of the tag to fit my book but I have a problem running it. When it gets to the line:
    if (app. selection. length> 0) {
    I get an error: undefined is not an object
    Can you offer any quick help? Thanks very much. Script below:
    / FirstAndNextStyles.jsx
    var myFirstPStyle = "X Appendix Co. Name";
    Object.prototype.isText = function()
    switch(this.constructor.name)
    case "InsertionPoint":
    case "Character":
    case "Word":
    case "TextStyleRange":
    case "Line":
    case "Paragraph":
    case "TextColumn":
    case "Text":
    case "TextFrame":
    return true;
    default :
    return false;
    if (app.selection.length > 0) {
    var myDoc = app.documents[0];
    for (oneSel = 0; oneSel < app.selection.length; oneSel++) {
    if (app.selection[oneSel].isText()) {
    // apply paragraph style to the first of selected paragraphs
    try {
    app.selection[oneSel].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.item (myFirstPStyle);
    catch(e){
    // apply paragraphs next style to the following paragraphs
    if (app.selection[oneSel].paragraphs.length > 1) {
    for (oneP = 1; oneP < app.selection[oneSel].paragraphs.length; oneP++)
    app.selection[oneSel].paragraphs[oneP].appliedParagraphStyle = app.selection[oneSel].paragraphs[oneP-1].appliedParagraphStyle.nextStyle;
    else if ((app.selection[oneSel].paragraphs.length == 1) && (app.selection[oneSel].paragraphs[0].insertionPoints[-1].paragraphs[0])) {
    app.selection[oneSel].paragraphs[0].insertionPoints[-1].paragraphs[0].appliedParagraphSty le = app.selection[oneSel].paragraphs[0].appliedParagraphStyle.nextStyle;

  • Zoom and pan with Ken Burns and then stop and hold the image

    Hi all,
    I'd like to zoom and pan on a photo with Ken Burns and then stop at the "end" -cropping and hold the image there on my project for a few seconds. Is this possible?

    I found a new solution.
    I select the ready "Ken Burnsed" photoclip and ctrl-click and choose copy, and then paste the exactly same kind of clip right behind the original. Then i go to the 'cropping, ken burns and rotation'- window, make shure that the start box is on the same crop as the ending of the original clip ( you can switch between start and end crops from the arrow thingy in the corner of the box) , and click crop. There I have the righty cropped stillframe right behind of the original.
    I don't know if this is the right method, but it works thanks for everyone for helping, and if you find a better way, please post. I have this thread subscribed.
    Message was edited by: AnttiS

  • GREP help "apply style before the ' – ' and add return"

    Hi,
    I'm a newbie to GREP and not good at code so I need some help.
    I think if I new the code to say " apply Heading Paragraph style to text before the ' – ' and add return.
    Then it would work.
    I'm OK with looping nested paragraph styles.
    This is what I have currently got:
    Nerang Community Respite Centre – 5578 1668
    Provides a podiatry service.
    www.nerangrespite.org.au
    Ozcare Allied Health Program – 5569 6200 / Fax 5578 1331 
    Physiotherapy, occupational therapy, speech pathology, podiatry, dietetics and social work.
    www.ozcare.org.au
    And this is how I need it formatted with styles applied
    Nerang Community Respite Centre (Heading Paragraph Style)
    5578 1668 (Phone Paragraph Style)
    Provides a podiatry service. (Descrip Paragraph Style)
    www.nerangrespite.org.au (URL Paragraph Style)
    Ozcare Allied Health Program (Heading Paragraph Sty
    5569 6200 / Fax 5578 1331  (Phone Paragraph Style)
    Physiotherapy, occupational therapy, speech pathology, podiatry, dietetics and social work. (Descrip Paragraph Style)
    www.ozcare.org.au (URL Paragraph Style)

    Thanks for the help so far. It's working but I still to iron some things out.
    Replacing the em dash with a paragraph space or return is straight forward. But getting the styles applied while doing that is not working.
    Also I want to split the phone and fax separated by the '/" onto separate lines.
    1. Not all the entries are the same see below example.
    This is what I have currently got
    ^p = paragraph
    Nerang Community Respite Centre – 5578 1668^p
    Provides a podiatry service.^p
    www.nerangrespite.org.au^p
    ^p
    Ozcare Allied Health Program – 5569 6200 / Fax 5578 1331^p
    Physiotherapy, occupational therapy, speech pathology, podiatry, dietetics and social work.
    www.ozcare.org.au^p
    Volunteering Gold Coast – 5591 8388^p
    Cerebral Palsy League of Queensland – 5532 2088 / Fax 5591 7725^p
    Provides community access to people with Cerebral Palsy and related disabilities.^p
    And this is how I need it formatted with styles applied
    Nerang Community Respite Centre (Heading Paragraph Style)
    5578 1668 (Phone Paragraph Style)
    Provides a podiatry service. (Descrip Paragraph Style)
    www.nerangrespite.org.au (URL Paragraph Style)
    Ozcare Allied Health Program (Heading Paragraph Style)
    5569 6200 (Phone Paragraph Style)
    Fax 5578 1331  (Fax Paragraph Style)
    Physiotherapy, occupational therapy, speech pathology, podiatry, dietetics and social work. (Descrip Paragraph Style)
    www.ozcare.org.au (URL Paragraph Style)
    Volunteering Gold Coast (Heading Paragraph Style)
    5591 8388 (Phone Paragraph Style)
    Cerebral Palsy League of Queensland
    5532 2088 (Phone Paragraph Style)
    Fax 5591 7725 (Fax Paragraph Style)
    Provides community access to people with Cerebral Palsy and related disabilities. (Descrip Paragraph Style)

  • ITunes Error 3194 then 21 then 1600 and maybe again 3194

    Hello my name is dvir, and i here to you guys will help me and support me pleaseror and no 1 time
    im here with a error and no 1 time, this happening to all many people's this happend's.
    i have a problem with code error 3194 but i fixed it. and now i have 21 and i try to fix it. then this change to 1600.
    i'm scard to reinstall the iTunes, then maybe all my backup's and the music list and all my thing will be removed.
    so please apple support help me or fix this problem.
    Thanks you. Have a Nice Day.
    Dvir.

    thank you for your help.
    i manage to fix it.
    what i did is update my itune to latest version then download 8.0.2 firmware for my ipod and then restore it to 8.0.2.
    so apple stop signing the ios 7 so i cant roll back to ios7. thank you though for your quick response i appreciate it a lot.

  • How do I (or can I) apply alternating para styles (using "next style") to existing text?

    I am trying to apply background shading to alternate lines of text by creating two paragraph styles and naming each as the "next style".
    This works when manually entering text - but I can't figure out if it is possible to apply it to existing copy with out applying the styles to each line individually.
    Thanks for any help
    d

    Select multiple paragraphs of text, then right-click on the name of your first style in the Paragraph Styles panel. "Apply Style, Then Next Style" should be one of the options.

  • Take screenshot and saves the image to a PNG file

    Hello,
    How can I take screenshot and save the image to a PNG file?
    thanks,
    Avivit.
    Solved!
    Go to Solution.

    this is a quite reproducible problem. Some more clarification on my part might help:
    I have a loop that contains, among other this, (1) a sub-VI that prints-screen and saves as a png and (2) a sub-VI that emails me the png file as an attachment. The 1st sub-VI simply uses the user32.dll to simulate a print-screen key stroke, calls clipbpard get image, and then formats and saves the image to a png file using the built-in VI write-to-png. This loop should update this same png file, because the path does not change. However, I've noticed that while the loop is running the png file does not update. It simply keeps sending the 1st image it took. The image updates if the VI stops and is run again. I assumed the problem was either with the clipboard not updating or the file not writing.
    I think the png file remains open while the main VI (i.e. this loop) runs because I cannot delete the file while the VI is running, only once it stops or is quit. Windows gives me an error that the file is currently in use by labview. Therefore, I think the file is not updated because it remains open.
    I've attached the print screen VI. Feel free to stick it in a loop and give it a try if you don't spot something obviously wrong. I did not include the main-VI that I actually use since it contains a lot of instrument I/O, which would prevent someone testing the VI.
    Attachments:
    PrintScreen.vi ‏18 KB

  • Delete specified line and next paragraph applied specified paragraph style

    Hi,
    How to find one of the specified line, then delete (e.g. <chapter>) and the next paragraph applied one of the paragraph style in the indesign javascript. Please explain

    Hi,
    Why do you want to use a [JS]? A simple grep search can do it:
    If you have to do it on other "<………>", do similar regex and use Multi-Find/Change! 
    Done with some work minutes!

  • Apply character or paragraph styles to notes and to do's in Mail ?

    Is it possible to:
    apply character or paragraph styles to notes and to do's in Mail ?
    ALSO:
    I would like to change things like-
    change the color of the default yellow notebook like ruled paper?
    apple character or paragraph styles to notes and to do's?
    Main calender for item related Dates
    The red icon next to the to-do items
    number of columns
    Hold/Insert/Link/Attach additional relevant files?
    Similair to other third party project organizational software such as OmniPlan / Schoolhouse/ KIT (Keep it Together)
    I was also thinking the ability to apply my mail rules to them would further their efficiency. Does anyone know if this is possible?

    In the preferences menu, under "composing" There is an option for "Create Notes & To Do's in:" With the options being "On My Mac" and "[email protected]".
    I did not have this set properly, and changing it meant that selecting text in a note and making a to do gave me the option of putting it in my local calendars.
    However, when I select text from an e-mail it still puts it in my "[email protected]" calendar.
    Partial fix --> Still not exactly what I want to see.

  • Clicking a Paragraph Style Does Not Apply Style to Text

    I just switched from a PC to a brand new MacBook Pro (OSX Lion 10.7), and I bought InDesign CS5.5. I have been using CS4 on a PC for a couple of years and had no issues. For some reason, I cannot apply Paragraph Styles by placing my cursor in the text and clicking the Paragraph style. It highlights the clicked style for a moment, and then de-highlights all the styles, but does not apply any changes. The only way I can apply a Paragraph Style right now is by right clicking the style and selecting "Apply..." from the drop down menu. It's very puzzling. I was wondering if anyone had any experience with this. I also have Microsoft Office: Mac 2011 installed on the laptop if that makes a difference to anyone. Any help would be greatly appreciated, since I typeset and edit for my living, and this problem is slowing me down a bit.

    Neither. Let's say I click into a paragraph. The current style will be highlighted. If I click on another style (or even attempt to re-apply the same style by clicking on it in the styles pane), it momentarily highlights the new style, then flashes a little bar underneath (like the one that shows up if I were to try to re-organize the styles list by dragging a style to a different pace in the styles list), then all the styles become unselected, but no changes have been applied to the paragraph in question. Very definitely not normal. It is almost as if the pane assumes that I am attempting to drag the style even when I am merely clicking on it. Very weird.

  • [AS] CS3- Find any text with style, then replace that text with a new applied fill color.

    I am trying to find the simplest way in cs3 to find any text with style, then replace that text with a new fill color. I can find text and change text. I can find a style and change it to a new style. I can't seem to find a style and change the applied fill color. I do not want to change the properties of the style, just the applied color. Yes, I want the + sign, for now. I know, why not update the style, I am not allowed to. Any help would be great. Since the search is not available, I need a new response.
    Thanks.

    You can work around the bug by just doing a find, then looping through the<br />results, changing the color one at a time. It'll be a fraction slower, but<br />should do the trick:<br /><br />tell application "Adobe InDesign CS3"<br />    set find text preferences to nothing<br />    set properties of find text preferences to {applied paragraph style:"The<br />name"}<br />    set theFinds to find text document 1<br />    repeat with i from 1 to count of theFinds<br />        set properties of item i of theFinds to {fill color:"Replace color"}<br />    end repeat<br />end tell<br /><br />The bug is fixed in CS4, BTW.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • Add style to next paragraph (by using GREP?)

    Can someone help? I have a problem - long (300+ pages) text with questions and answers. Questions are using paragraph style "x" and answers are using paragraph style "y". There are usually 3-6 paragraphs of text in every answer. I need to change only the first paragraph's style after the question paragraph to style "z", so that the structure of styles would look like  x-z-y-y-y-y-x-z-y-y... (now it looks x-y-y-y-y-y-x-y-y-y...). Can it be done using GREP somehow?
    Claudius

    I sell a script on my website for this sort of thing:
    www.freelancebookdesign.com
    Under the "Scripting" tab, check out a script called "Change Consecutive
    Paragraphs".
    Ariel

  • Create/find tables and apply style

    Hello,
    I'm very new to scripting. I want to learn the basics like creating a table, creating anchored frames, textframes, etc.
    Now, I want to create/find tables in a document and I would like to apply styles. I saw a script to do this. When I paste the script in Extendscript CS4, than the program crash.
    The program crash in part 1. When I create another script with only part 2 (see //part 2) then there is no problem.
    What do i wrong? And can anyone tell me what part 1 of the script do?
    Thanks,
    // part 1
    // using your version; I'd prefer to return 0 if table not found
    function findTable(obj) {
             while (obj.constructor.name != "Table") {
            obj = obj.parent;
            if (obj.constructor.name == "Application") {
                throw "Can't find table"
        return obj
    // part 2
    var myTable = 0;
    if (app.documents.length > 0 && app.selection.length > 0)
        myTable = findTable(app.selection[0]);
    // check for at least enough rows for 1 top row, 1 body row, 1 bottom row
    if (myTable != 0 && myTable.rows.length >= 3) {
        // delete all rules; set insets to 0
        myTable.cells.everyItem().appliedCellStyle = "[None]";
        // format bottom row
        // (remember rows uses 0-based count)
        a = myTable.rows.length - 1;
        myTable.rows[a].cells.everyItem().appliedCellStyle = "4.cell_body_last";
        // format middle rows
        first = 1;
         last = myTable.rows.length - 2;
        for (a = first; a <= last; ++a)
            myTable.rows[a].cells.everyItem().appliedCellStyle = "3.cell_body";
        // format top row
        a = 0;
        myTable.rows[a].cells.everyItem().appliedCellStyle = "2.cell_header";

    Part 1 expects the text cursor to be anywhere inside a table -- either in the regular text, or with a cell, row, column, or the entire table selected.
    It walks "up" using its parent until it arrives at the table object itself.
    This will only work if the text cursor actually is anywhere inside a table. It does nothing when you are somewhere else, and it only works with the "current" table.

  • When I open a raw file (NEF Nikon 7100)  and apply setting then click save, I get an error ( could not complete your request because of a program error ). Ideas?

    when I open a raw file (NEF Nikon 7100)  and apply setting then click save, I get an error ( could not complete your request because of a program error ). Ideas?

    Oh, dear.
    If you use PSE as your external editor for iphoto, you need to save the images back to iphoto by using Save, not Save As and not changing anything like the name or format that would bring up the Save As window. (You may need to adjust the editor prefs>saving files>on first save to save over existing.)
    OR you can export the photos from iphoto to the desktop, use file>open in the editor and then change whatever you want and either import the saved image to the organizer or import it back to iphoto as a new file. What you are doing is extremely risky, particularly to the iphoto library which you may easily damage by your workflow.
    I would start the organizer holding down the shift key, then create a new catalog and switch to the new one. Then try opening the editor without opening an image and see if you get any farther.
    PSE and iphoto are not designed to be used as you've been doing. You are trying to write to the iphoto library from outside iphoto, which is the fastest known way to corrupt the library and lose all your photos.

  • How to remove the sort function on the drill down and then save

    how to remove the sort function on the drill down and then save in the  change local view of the Query
    Is it possible to change the porperties of any characteristic in the local view and then save?
    If so please post the answer.

    I do not think that option is possible.
    Regards,
    Venkata Boga.

Maybe you are looking for