AppleScript to delete numbers 1-99 in a specific context (Pages)

Hello!
I would like to have an AppleScript to execute the following in a Pages document
Delete all numbers from 1 to 99 in the document
only if the following criterias are met
Numbers are not in a table
Numbers must be located on the line preceeding a table only
Numbers must be at the beginning of the line
Any help would be appreciated!!
Thanks

The following script, though not blazing fast, seems to work:
tell application "Pages"
    activate
    set theCount to count tables of body text of front document
    repeat with k from 1 to theCount
        select table k of body text of front document
        tell application "System Events"
            -- Select the paragraph before the table:
            key code 123
            key code 124 using {shift down}
            key code 123 using {shift down, command down}
        end tell
        try
            -- Delete the paragraph if it contains only a number between 1 and 99:
            get contents of selection
            set theNumber to result as integer
            if theNumber > 0 and theNumber < 100 then delete selection
        end try
    end repeat
    -- Place the insertion point at the beginning of the document:
    tell application "System Events" to key code 126 using {command down}
end tell
Message was edited by: Pierre L. (removed the line “get text 1 through -2 of result”)

Similar Messages

  • How to recover a deleted numbers file in icloud

    How do I recover a deleted numbers file that was saved in icloud
    Can files be saved on Mac and I cloud at the same time

    Use your back up/Time Machine to look inside the user library > mobile Documents folder.

  • How do i delete numbers you have text

    I have been trying to delete numbers that i have text in the past and i want to get rid of now

    The number will go away if you have read all messages you got. If you did and the number is still there, try to reset the phone by holding the sleep and home button for about 10sec, until the Apple logo comes back again.

  • How do I permanently delete Numbers files on the iPad?

    Friends:
    How do I permanently delete Numbers files on the iPad? I use the trash button, and they seem to be deleted, but they are not. If I leave Numbers and come back, I can still load the deleted files!
    How do i permanently delete them?
    Thanks
    Migs

    Do you mean to delete them from numbers, or from the shared folder location in the upper right? The previous poster was addressing the second. If you want to completely delete something from the iPad, you must do both, the trash can icon when e current workbook is in front of the list, and swipe to delete from the shared folder list. It's two completely different locations.
    Jason

  • How can I permanently delete numbers from my iPhone without them having to show up under messages!

    Okay so I've deleted numbers from my contacts list and whenever I go to my messages and tap on the icon to write and message to someone that I do have on my phone the people numbers I deleted from my contacts list still show up is there anyway I can't delete those numbers for good?

    Is it actually downloading or simply transferring content from the iPhone to the iTunes library?

  • Applescript to delete Messages conversations

    I'd like an Applescript that deletes all my iMessage conversations in the Messages app.
    Could somebody please tell me how to get all my conversations and then delete them using Applescript? Thanks!

    Can you clarify your request?
    More specifically, explain what you want a script to do differently than the Messages preference option to (not) 'save history when conversations are closed'?
    From your description it sounds like the easiest option is to just turn on that preference setting, and your history won't be saved, and therefore won't need to be explicitly deleted.

  • AppleScript to Delete iTunes Tracks & Files but Retain in Cloud

    Hi, first of all, thanks ahead of time to anyone kind enough to help me out here.
    I've created a playlist with iTunes tracks that are under 256 kbps and were matched on iTunes Match.
    I need an applescript that deletes those tracks from my iTunes and moves the files into the trash, and then initiates Download (from the matched files on the cloud) on those tracks.
    Thank you very much. Appreciate it.

    But you are saying that Show in Finder takes you to the expected file in the expected location?
    I should have asked you before, but what version of OS X and what version of iTunes are you using?
    I am also confused by what you're saying about deleting a track in the iTunes library (with or without OPTION held as it should not make a difference here): when you delete a track that has a local file, you should get a warning asking "Are you sure you want to delete this copy of ..."  This dialog also has the option to check to delete from iCloud as well.  If you agree, the file will be deleted but the track will remain with the icon to allow you to download from iCloud.  When you delete a track that is only in iCloud (i.e. has no local file) you should get a warning "Are you sure you want to delete this .... from iCloud", then the track will be deleted from your library and from iCloud forever.
    Did you get any warning dialogs?

  • After updating numbers and pages I can no longer copy multiple cells from numbers and paste and match style to pages.

    After updating numbers and pages I can no longer copy multiple cells from numbers and paste and match style to pages.  I used to be able to select multipule cells in a row (such as company name, address, etc.) then paste and match style on to a pages letter. I found the paste and match style option in the edit menu, however it will only work one cell at a time. Before the update is was working great.

    For diagnosing purpose thy the procedure in a new user account and see if it works there. You create a new user account in the System Preferences > Accounts. If it works in the new account it is probably a corrupt plist file that needs to be deleted.

  • Why is it that when I go to Yahoo mail, I can't delete any messages or move to the next page? Stays stuck on page 1..

    Lately, when I log on to my yahoo mail while using firefox, it no longer shows the DELETE option at the top of the email page. So, I cannot delete any emails that I might wish to delete. Also, I cannot get past the first page of my emails. Every time I click on the NEXT PAGE button, it does not move from page 1. This does not happen when I log onto yahoo mail using Internet Explorer. Please advise as to what I can do to correct this. Could it be that I'm not using the latest version of Firefox? I don't know...

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • How do I add or delete a quick link from Firefox's home page.

    How do I add or delete a quick link from Firefox's home page. I don't use most of the links and would like to add other quick links.

    You can change the order of the boxes on the about:newtab page and drag an item to a different slot to pin it to that position or you can remove a website by clicking the close X to block that URL.<br />
    You can drag a bookmark or history item and drop them in a slot on the about:newtab page to pin them and have your own favorites sites showing.
    Changes made manually on the about:newtab page are stored in the browser.newtabpage.pinned (default = [null]) and browser.newtabpage.blocked prefs that you can check/modify on the about:config page (Bug 791447).
    *http://kb.mozillazine.org/about:config
    See also this article about the New Tab page (about:newtab):
    *https://support.mozilla.org/kb/new-tab-page-show-hide-and-customize-top-sites

  • Well, i was on my laptop now and all of a sudden a pop up message appeared and said "your download is complete" so i went to go check it out and it was 'MacProtector'. i cant delete it and it keeps opening unwanted web pages, please help me sort this out?

    Well, i was on my laptop now and all of a sudden a pop up message appeared and said "your download is complete" so i went to go check it out and it was 'MacProtector'. i cant delete it and it keeps opening unwanted web pages, please help me sort this out someone?

    Refer to:  http://cantalktech.com/2011/05/08/mac-protector/.

  • I deleted the gmail app from my ipad home page.  how do i retrieve it?

    I deleted the gmail app from my ipad home page.  how do i retrieve it?

    from the app store - update - purchased - find the app and hit the cloud to redownload.

  • Can't find a way to delete Templates from the "My Templates" window in Pages.

    How can I delete Templates from the "My Templates" window in Pages?

    If you want to delete user-made templates, go to ~/Library/Application Support/iWork/Pages/Templates and you'll find the individual files that you can just delete.
    If you want to delete iWork's own templates, that's a bit trickier.  Right-click (or Control-Click) on the Pages application, choose Show Contents.  Drill down to Resources and Templates and there they are.  I'm not sure I'd delete anything from the application package, however, so my advice would be to copy the app and try it on that to make sure it doesn't foul anything else up.
    Good luck.

  • I have accidently deleted the App store icon off my home page, how do I get it back, do I need to re down load?

    I have accidently deleted the App store icon off my home page, how do I get it back do I nave to re download??

    Swipe through your screens and swipe to the left of your Home screen. Type in App Store in the search field. It's a permanent pre installed Apple app so it can't be deleted.
    If you can't locate it on the iPad for some reason, connect the device to your computer. Right or control click the iPad under Devices left side of the iTunes window then click: Restore from backup

  • The delete icon at the bottom of the email page has disappeared

    The delete icon at the bottom of the email page has disappeared.  How can I find it?

    Restart iPhone: Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for phone to restart (no data will be lost).

Maybe you are looking for