AppleScript Help Needed - Delete Empty Rows
I'm using OmniOutliner Pro to open text files and then export them as Keynote Presentations. When I do this, I invariably need to delete some empty rows that are created when I open the text file in OmniOutliner. I'd like to automate this process if possible, but I'm a complete newb when it comes to scripting. Can anyone help me with this conundrum?
|
Hi!
A while back I wrote a script to do this very thing. Here it is: [CODE]tell front document of application "OmniOutliner Professional" delete (rows whose topic is "") end tell[/CODE] That's it! Save that as a script and put it in your OmniOutliner scripts folder, and you're set. |
That's great. Thanks so much for the response.
|
I find myself importing quite a lot of text files at the moment.
OO3 does this well, often preserving various kinds of indentation. Unwanted blank rows are, however, common, and often need to be removed. A slightly more cautious approach than the very useful script above might involve:[LIST=1][*][I]Selecting[/I] blank rows rather than immediately zapping them, (gives a chance to check)[*]preserving rows which have no topic but [B]do[/B] have a note.[/LIST] [CODE]tell application id "OOut" to select (rows of front document where topic = "" and note = "")[/CODE] (Even this, of course, may be too bold if there are additional columns which might contain data while the topic and note are blank) |
A sketch of something more cautious:
Aims to select only [B]completely[/B] empty and childless rows. (unchecked and childless, with neither topic nor note, nor any data in any other columns). [CODE]-- Ver 0.2 A little faster in documents without additional columns -- SELECT ALL COMPLETELY EMPTY ROWS -- i.e. rows which: -- 1. ARE UNCHECKED -- 2. HAVE NEITHER TOPIC NOR NOTE -- 3. HAVE NO DATA IN OTHER COLUMNS -- 4. HAVE NO CHILDREN property plstEmpty : {"", missing value, "unchecked"} tell application id "OOut" if (count of documents) < 1 then return select my EmptyRows(front document) activate end tell on EmptyRows(oDoc) tell application id "OOut" tell oDoc -- COLLECT A LIST OF UNCHECKED CHILDLESS ROWS WHICH HAVE NEITHER TOPIC NOR NOTE, set refRows to a reference to (rows where topic = "" and note = "" and state = unchecked and has subtopics = false) -- AND WHICH HAVE NO DATA IN ANY OTHER COLUMNS if (count of columns) > 2 then set lstEmpty to {} set {lstID, lstValue} to {id, (value of cells)} of refRows repeat with i from 1 to length of lstID set blnEmpty to true repeat with oValue in item i of lstValue if oValue is not in plstEmpty then set blnEmpty to false exit repeat end if end repeat if blnEmpty then set end of lstEmpty to item i of lstID end repeat else return contents of refRows end if -- CONVERT ID LIST TO LIST OF ROWS repeat with i from 1 to length of lstEmpty set item i of lstEmpty to (row id (item i of lstEmpty)) end repeat end tell return lstEmpty end tell end EmptyRows [/CODE] [COLOR="White"]--[/COLOR] |
All times are GMT -8. The time now is 01:21 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.