The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
AppleScript Help Needed - Delete Empty Rows Thread Tools Search this Thread Display Modes
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
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:
  1. Selecting blank rows rather than immediately zapping them, (gives a chance to check)
  2. preserving rows which have no topic but do have a note.

Code:
tell application id "OOut" to select (rows of front document where topic = "" and note = "")
(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 completely 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
--

Last edited by RobTrew; 2011-09-23 at 03:07 AM.. Reason: ver 0.2 - a little faster in documents without additional cols
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
add/delete rows/columns in a table. fantzhi OmniGraffle General 1 2014-04-21 08:46 AM
applescript to delete duplicate tasks jamesafoster OmniFocus Extras 1 2013-04-02 08:55 AM
Delete button deleting previous rows jjdoyon1 OmniPlan General 1 2010-01-25 10:36 PM
AppleScript help needed for ow5 & oo3 sangheeta AppleScripting Omni Apps 3 2008-04-03 02:04 PM
Can’t empty trash / delete older OF version nggalai OmniFocus 1 for Mac 1 2007-12-12 08:15 AM


All times are GMT -8. The time now is 11:40 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.