Deleting paragraphs in TextEdit

Hi there,
   I'm having some issues deleting certain paragraphs in a document.  I want to delete every paragraph which doesn't start with '{'.  I have done this so far:
tell application "TextEdit"
  activate
          open "/Users/John/Desktop/map.rtf"
          set this_text to the text of document 1
end tell
set the paragraph_list to every paragraph of this_text
repeat with i from 1 to the count of paragraphs of this_text
          set this_paragraph to item i of the paragraph_list
          try
                    if first character of this_paragraph is not "{" then
  delete item i of paragraph_list
                    end if
          on error  --If there isn't any character
  delete item i of paragraph_list
          end try
end repeat
I don't know what I am doing wrong.  Thanks in advance.

In plain words, I want to delete a paragraph if it contais the words "Water":"0"  That's why I tried to use 'if offset=0', Am I wrong? (again? )
You were nearly right! See below:
set theNewText to ""
tell application "TextEdit"
    set theText to text of front document
    repeat with k from 1 to (count paragraphs of theText)
        set thisParagraph to paragraph k of theText
        if (length of thisParagraph > 0) ¬
            and ((offset of "\"Water\":\"0\"" in thisParagraph) is 0) ¬
            and (character 1 of thisParagraph is "{") then
            set theNewText to theNewText & thisParagraph & return
        end if
    end repeat
    make new document at front with properties {text:theNewText}
    activate
end tell

Similar Messages

  • Deleting paragraph format

    how to delete paragraph formats in sap scripts

    Hai Ram,
                    You can create and delete any elements in sap scripts easily.
                    If U want to delete a paragraph format just double click on it,
                    and click on edit in menu bar and select deete element.
    Thanks and regards
    sekhar.c

  • Deleting paragraph tags that are in use is allowed in FM 9!

    Has anyone besides me noticed that FM 9 allows you delete a paragraph tag in a document even though the paragraph tag is in use? I've found that the result of deleting the tag is that text with that tag is unaffected and even still has the deleted tag applied to it. However, the tag is no longer selectable from the paragraph tag list. FM8 would prompt would warn you that its in use before you attempt to delete it.
    The above behavior is at least the case for documents that I've used that were originally created in FM 8. Anyway, this lack of warning makes it darn impossible to efficiently remove unused tags from a document.
    Thanks.
    -Kurt Euler

    kdeuler wrote:
    Has anyone besides me noticed that FM 9 allows you delete a paragraph tag in a document even though the paragraph tag is in use? I've found that the result of deleting the tag is that text with that tag is unaffected and even still has the deleted tag applied to it. However, the tag is no longer selectable from the paragraph tag list. FM8 would prompt would warn you that its in use before you attempt to delete it.
    Kurt,
    I'm not sure why you think that FM8 has been different… it isn't. Every version of FM has always allowed to delete paragraph styles, no matter if they are used or not. Paragraphs using the (deleted) format are now shown with an asterisk, like an overidden format, while keeping all attributes.
    This is why 3rd party vendors like ITL sell FrameScript scripts, which only delete unused styles and objects from documents.
    Bernd

  • How to delete columns in TextEdit?

    Well, for a "power" user, veteran word processor, table star, help reader, Google user, and board browser, I've been unable to figure this out!
    I also couldn't figure out where to post this (no TextEdit forum!).
    So, what happened was that I copied and pasted several rows and coiumns from a spreadsheet and want to delete couple of the columns. I figured out that one can highlight columns using the option key, but then delete removes the text not the column!
    It's probably something obvious, but I haven't found it!

    Hi
    Does this help, quoting TextEdit Help:
    Adding a table to your document
    You can create tables in TextEdit documents to organize information.
    Place the cursor where you want to add the table.
    Choose Format > Text > Table.
    In the Table window, type the number of rows and columns you want (or use the arrow buttons to add or subtract rows and columns).
    To adjust the height or width of a row or column, place the pointer over the border of a cell. When the pointer changes to a double arrow, drag the border to change the dimensions of the row or column.
    Steve

  • Does deleting paragraph styles affect documents which used a deleted style?

    Assume you have a web page or site made with paragraph styles.
    You start a new page in that site but decide to delete a bunch of paragraph styles which you  no longer want
    The style should be in the html of the earlier documents and deleting the style should not delete the existing HTML.
    But with Muse you never can be sure.
    So is it ok to clean up the clutter and delete a bunch of old styles when creating something new or not?
    Please do not respond unless you actually know the answer. No guesses please.

    Hi Jkijki,
    If you have created a paragraph style and applied to a paragraph, when you try to delete that paragraph style you will get option to replace the paragraph styling with another style (if there exist any):
    Check this link: http://prntscr.com/3p9c5x
    Regards,
    Gaurav Aggarwal

  • CS3 Find Font/Delete Paragraph Style/Redefine Paragraph Style Causes Crash

    I am running into a very frustrating issue where I cannot replace a paragraph style. The issue is that we used to use some adobe type fonts and want to move to the true type equivalent so that we don't have problems working on files between mac and pc. The problem occurs on both mac and pc on a variety of hardware (both c86 and ppc macs for example). When we open the document it identifies that the font cannot be found (example Palatino T1). When we click find font and select the regular ttf Palatino replacement and click Change All Indesign just vanishes and leaves a crash message with a ton of garbage and a read only memory error. The same happens if we change the font on some text and right click on aragraph style and click "redefine style" - there is a sudden crash.
    Trying to work around this I went into our templates and tried to change it there. Opening the paragraph style and selecting the new font caused it to crash upon selecting OK. Also trying to Make a new paragraph style works, but then when deleting the old one causes a crash no matter what combination of mapping or not mapping the old paragraph style we chose (we tried every option under the dialogue and selected several different styles to map to or none at all).
    This occurs on several different fonts and on several different templates. I have tried deleting the adobe font cache to no avail. Any help resolving this would be great - all our employees are going nuts over this problem.
    Thanks in advance for any help or suggestions!

    Peter, your latest post led me to an interesting revelation. When I change Palatino (t1) bold to Palatino Bold using Find/Change it is fine. When I change Palatino (t1) to any font using Find/Change there is a curious result! As soon as I click find first the page changes to the default template and all content is hidden. The 4 or 5 places where palatino occurs on the default template change fine, but then on the next click of FIND FIRST it crashes! So the problem is connected to "find first", not the actual change. My guess is this is an issue of with how the find/change jumps from the template to the individual page, but I'm not sure exactly what is happening.

  • SAP Script - delete paragraph between two lines or move address one line up

    Hi all,
    i have a problem concerning SAPscript and formating.
    In the address window i have an include, which provides a text in a line. after that i have a command line with address and paragraph, which sorts and formats the address. Problem is that there is a gap between my Text from the Include and the address. Is there a way to move the address one line up or any other way to delete the paragraph there?
    SAPscript looks like this:
    include ....
    endif.
    adress paragraph zz
    name  Testname
    street teststreet
    Postalcode 98788
    City  Town
    Print Form:
    Text from the include
                                          <----
    how can I get rid of this empty line?
    Testname
    teststreet
    98788 Town
    Any Suggestions?
    Thanks,
    Denis

    Hi there,
    no results yet. nothing worked so far. What does PB mean?
    The CODE looks as follows:
    /: if ....
    /: include ........ new-paragraph SA
    /: endif
    /: if ....... OR ....
    /: address Paragraph AS
    /: name  ......
    /: street ......
    /: endaddress
    Print::
    Text blablabla
                                  <---- empty line
    Name .....
    Street .....
    The include has no empty line in the end.
    I have no more clues how to delete the empty line in between the address and the include text.
    regards,
    denis

  • Trouble deleting paragraph styles

    I have a book with five documents in it. I am trying to delete some paragraph styles but they just don't want to go away. I keep deleting them from one of the documents, then I make that document the style source, synchronize the other documents with it, and the styles keep reappearing. I've tried doing it with different documents but I still get the same result.

    Syncing book  doesn't delete styles only adds.
    Just open each file (only 5 of them) and remover the styles...they are pobably used somewhere.

  • Delete paragraph format once for a whole book

    Hello,
    I want to delete a paragraph format at one place/one time in a book for every file in this book.
    Is that possible?
    Kind regards
    Nina

    You might want to try Paragraph Tools -- A plug-in for FrameMaker.
    With it, you can create a list of all paragraph tags in use for the book. You can delete the tag or tags you don't want. Then you can run the "Remove non-list tags" routine. All the tags still in the list are kept. Any others will be removed from your documents. The whole process should take less than 10 minutes, even if the book is enormous.
    Read more about it here:  http://www.siliconprairiesoftware.com/Products.html
    Steve

  • How to delete paragraph marks (returns) without affecting spacing, like at the top of the next page

    if you have a large document and you add two returns at the end of every major section or group but one of the two returns goes to next page, how do you keep that return so it doesn't mess up spacing if something is added earlier in document but get rid
    of it so the top of the page is the same as the other pages? I was wondering if there was something like a hidden return that would hide the paragraph at the top of the page but if more information was added before it, it would act like a regular return. Hope
    this makes sense.
    Also do you know what the paragraph maker with a dotted box around it is? I was trying to solve the above problem by trying different keys with the return key, e.g. control + return gives you a page break, shift + return gives you a soft return,
    control + alt + return gives you this funky paragraph symbol that seems to erase lines in front of it at least it did when I printed out a page using them.

    Thank you! I've never used Styles but have used the formatting. I just didn't want to have to go to the bottom of every page and change the paragraph formatting but format painter helped a lot. Thanks again.
    You could also use a heading style for the start of your next major block of text which is formatted to have a page break before. Styles are at the heart of Word formatting. Take the time to learn about them to save a lot of time and hair pulling.
    Read the
    link that Stefan gave you. If you want more, see
    Understanding Styles in Microsoft Word.
    Charles Kenyon Madison, WI

  • How to delete multiple variables from the variables list

    Hello,
    Iam using FrameMaker 9.0. Is there a way I can select multiple variables from the book and delete them together.
    Thanks,
    CP.

    NO in FM9. Take SQUIDDS TOOLBOX the free tool: 'Formats'
    'Formats' is a very helpful tool for 'deleting' paragraph formats, character formats, cross reference formats, table formats, color definitions and variables.
    You can delete unused one or all formats of selected. For paragraph and character you can also decide to 'add new one in catalog'.
    -Georg

  • The Delete Speed Test for Pages 2

    Hello Pages fans,
    “Speed” is a subjective term, so I wonder what people will find if they do this test:
    Paste a phrase such as “The quick brown fox jumped over the lazy dog’s back. ” ten times to make a dummy paragraph. Put the cursor at the end of the paragraph and press and hold the delete key and count the seconds it takes to delete back through the the entire paragraph, letter by letter. (This will depend on the key repeat rate you set in System Preferences.)
    If I delete a particular paragraph this way using Pages 2, when viewing the document in narrow format (i.e. viewing “fit page”) it takes about 22 seconds. If I view “fit width” and stretch the width across my 23-inch cinema display the same task takes about 101 seconds.
    Using Pages 1 it takes about 22 seconds (“fit page”) or about 27 seconds (“fit width”). Not as bad.
    I have tried every single fix proposed in this discussion forum to speed up Pages - to no avail. I am using a Mac Mini 1.42 GHz with 1GB RAM, a 23-inch display, 10.4.5 and the very latest updates. I have no other problems whatsoever in any other applications.
    Incidentally, In Word 2004 the same exact test takes about 17 seconds no matter what (whether viewed at 10%, 500% or anything in between).
    Trust me- I don’t actually sit around deleting paragraphs like this all day, but I do notice a very annoying typing lag. I’ve basically given up on Pages as a serious writing tool because of this typing lag / speed issue and gone back to Word. Pages 1 works fine and served my purposes for a year, but what future does the Pages application have if version 2 performs so poorly?
    Do those who report having blazing fast Pages 2 performance experience this problem with this test?
    Yes, this is a dreadfully boring test! But at least it’s not subjective and it’s not as iffy as watching the system monitor percentages jumping around.
    Thanks in advance for any responses.
    various macs...   Mac OS X (10.4.4)  

    True, MMINSO, I can just go use some other word processor. (Thanks for the tip.) I'm sorry to laugh at your suggestion but you entirely missed the point of my keyboard input test when you told me to just delete the whole paragraph at once.
    Ee gads... we could start a flame war over this! Can anyone think of a better, more reliable speed test to measure how Pages handles keyboard input?
    When I type text while viewing a document at full width across my screen, the typing is much slower than when I view the document tiny size. The typing lags. By "lags" I mean that the keyboard input is behind what I am typing. I devised a mind-numbingly simple little keyboard input test to replicate this problem perfectly. Again: This test directly replicates the type of keyboard input slowdown problem I encounter while doing normal typing. So it's certainly relevant, and it's also measurable and replicable.
    Naturally, it's not the actual number of seconds that counts, it's whether any given keyboard input task slows down when we do it viewing at different widths. The keyboard input rate changes, you see.
    I had hoped that someone would verify whether they experience the same lag in typing under the same conditions. In other postings, others have simply described the problem as "infuriating" and dropped Pages entirely. I don't think that's very useful. I was trying to be a bit more scientific about it in the hopes that it might actually be helpful.
    Maybe there's a better way to accurately demonstrate keyboard input lags in Pages?
    Maybe my machine is the only one experiencing any slowness.

  • I accidentally deleted Dictionary and can't find my install CD?

    I accidentally deleted Dictionary (and TextEdit, but I don't really use that one). ((And yes I emptied the trashcan))
    I thought they were just shortcuts, but I guess not.
    And now I can't use the three-finger tap to look things up. Is there any way to retrieve Dictionary without reinstalling?

    MacBook Pro, Mac OS X (10.7.5)
    Oops, I didn't see the signature

  • Looking for Pages script to find "return" "return" and delete 2nd one only

    Looking for a Pages Applescript to find "return" "return" and delete 2nd one only. Perform on entire document.
    Thanks

    Funny, the same question was asked on 2011/11/12 in http://macscripter.net/viewtopic.php?id=37477
    Nigel Garvey posted a neat answer :
    --{code}
    tell application "Pages"
       delete (paragraphs of front document whose length is 1)
    end tell
    --{code}
    Yvan KOENIG (VALLAURIS, France)  lundi 14 janvier 2011 11:01:29
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Missing Font, But Font Isn't In the Document

    Hello,
    We're all using FrameMaker 10 on Windows 7.
    My client and I are receiving the good old missing fonts error message, specifically:
    The "ITC Stone Serif Std Medium Ital Italic" Font is not available.
      It will be replaced by "Times New Roman Italic".
    The "ITC Stone Sans Std Semibold" Font is not available.
      It will be replaced by "Times New Roman".
    First, the fonts are installed.
    Second, Remember Missing Font Names is turned OFF. (Unchecked, cleared, etc.)
    Third, the fonts are NOT in the document. I have saved the document as MIF. I have searched for the font names. Nothing. When I open the MIF file in FM, I don't get an error. But I save it as a .fm file, open it, and I receive the same error messages.
    We don't use these fonts. We don't want them in our documents. I'm doing a massive clean up to get rid of old formats. About half of the files do not have any problems, but half do. I have tried everything:
    - Generating a list of fonts. If the fonts are found, then I go in and manually apply the Default Para Font. Usually, doing this removes the font from the list of fonts. However, I still get the messages.
    - Importing formats from a known good file. 
    - Editing the MIF, to the point of removing the entire paragraph, character, font, and table catalogs. (I started by deleting references to ITC Stone x, then went on to the more drastic measures.)
    - Changing the default printer.
    - Copying the text and pasting it into blank files based on known good files.
    - I tried editing the maker.ini file to substitute fonts directly, but that didn't work. I may have been doing that wrong, though. 
    I've got over 10 years of FM experience, and I've never encountered a font problem that editing the MIF couldn't fix.
    All of the documents came over from Frame 6. They're all in the same book.
    We need to be able to work on the book file as an entity, without having to open the files that contain errors and leave them open.
    Does anyone have any ideas?
    Thank you very much!
    ~Robyn

    I found the problem, but I'm not sure why it was a font problem to begin with:
    Unresolved cross-references.
    FM couldn't open all of the files in the book. Therefore, it couldn't update cross-references. It "thought" cross-references were unresolved.
    I figured this out by deleting one page at a time from a Bad file. Then, I deleted one paragraph at a time from the Bad pages to determine that the cross-references were causing the problem.
    I was cleaning up the book - deleting paragraph, character, cross-reference, table, and conditional text formats and master and reference pages. I then imported formats from a known Good file. The more files FM could open without errors, the fewer font errors I received. After I was able to generate/update the book, the font errors were gone.
    Some of the font calls were on a reference page that was found only in select files. However, one would think that would show up in the MIF.
    My best guess is that FM couldn't update the cross-reference formats without updating the cross-references, so it "thought" the text was still in the wrong font. That begs the question: Which came first, the unresolved cross-references or the missing fonts?
    Of course, it doesn't explain why FM was complaining about a font that is installed.
    Thank you everyone who took the time to answer. I'm sure this won't be the last time I run into this problem, and now I'll have a lot more knowledge for next time.
    ~Robyn

Maybe you are looking for

  • Jpegs won't open in Dreamweaver cs4 or Dreamweaver 8

    I was using dreamweaver 8 just fine and then all of a sudden my newly created jpegs won't transfer to dreamweaver.  They won't open no matter what program I create the jpeg in.  The old ones that are saved on my desktop or image folders will still op

  • How can I do to return a version of iPod software?

    I have iOS 4,3,5 but I want to come back to 4.3.3 or previous.

  • One Slide Won't Export to iDVD

    I have a Keynote Presentation that I made, from scratch, in Keynote. I used the Record feature to add narration. However, when I "Send to iDVD" or even simply "Export to Quicktime," the second slide will not export. The audio that is supposed to acco

  • Cloning the internal disc

    Dear Pros, I'am trying to clone an original internal harddisk with 160 GB in one of my G5 to a new one with more capacity. I tried with the disk utility (made a dmg an back to a new hd), Carbon-Copy-Cloner and Drive Genius. The result is always, that

  • Powerbook G4 12" won't start

    I have a PowerBook G4 (12" aluminum). It seems like the battery has been getting weaker and weaker over time. Lately, if the power cord slips out, the computer shuts down immediately, and the LED lights on the battery show nothing when the button on