Convert NOTES to ROWS heeeeeeelp!

Is there any way that this can be done? i have thousands of container rows and this has become tedious. I browsed everywhere and couldn’t find anything. I know there is a script where you can convert rows to notes but couldn’t find anything on converting notes to rows. Please help

First draft — try this script in a test document.

Usage:

  • Select rows whose notes are going to be converted into rows.
-- V0.01
-- unlocked2412

on run
	tell application "OmniOutliner"
		set oDoc to front document
		script
			on |λ|(strID)
				tell oDoc
					set oRow to row id strID
					make new row with properties {topic:(note of oRow)} at before first row of oRow
				end tell
			end |λ|
		end script
		my map(result, my map(getRowByID, my filter(hasNote, selected rows of oDoc)))
	end tell
end run

on hasNote(oRow)
	using terms from application "OmniOutliner"
		note of oRow ≠ ""
	end using terms from
end hasNote

on getRowByID(oRow)
	using terms from application "OmniOutliner"
		id of oRow
	end using terms from
end getRowByID

-- GENERIC FUNCTIONS --------------------------------------------

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
	tell mReturn(f)
		set lng to length of xs
		set lst to {}
		repeat with i from 1 to lng
			set end of lst to |λ|(item i of xs, i, xs)
		end repeat
		return lst
	end tell
end map

-- Lift 2nd class handler function into 1st class script wrapper 
-- mReturn :: Handler -> Script
on mReturn(f)
	if class of f is script then
		f
	else
		script
			property |λ| : f
		end script
	end if
end mReturn

-- filter :: (a -> Bool) -> [a] -> [a]
on filter(f, xs)
	tell mReturn(f)
		set lst to {}
		set lng to length of xs
		repeat with i from 1 to lng
			set v to item i of xs
			if |λ|(v, i, xs) then set end of lst to v
		end repeat
		return lst
	end tell
end filter
1 Like

This is great as it does convert the notes into rows however, it keeps the notes as well. Don’t get me wrong, this is another script I wish I had a billion years ago and I can’t thank you enough for making this one but my task at hand is getting rid of notes and converting them to rows. this would save me the additional process of cut paste + mouse click for each note, still a progress!! Can you help me delete those notes at the same time?

this is more like a duplicate note to child row

You’re welcome.

It’s possible to delete notes, also. Always try it with a test document.

Tell me if it does what you intended.

-- V0.03
-- unlocked2412

on run
	tell application "OmniOutliner"
		set oDoc to front document
		script
			on |λ|(strID)
				tell oDoc
					set oRow to row id strID
					make new row with properties {topic:(note of oRow) as text} at before children of oRow
					set note of oRow to ""
				end tell
			end |λ|
		end script
		my map(result, my map(getRowByID, my filter(hasNote, selected rows of oDoc)))
	end tell
end run

on hasNote(oRow)
	using terms from application "OmniOutliner"
		note of oRow ≠ ""
	end using terms from
end hasNote

on getRowByID(oRow)
	using terms from application "OmniOutliner"
		id of oRow
	end using terms from
end getRowByID

-- GENERIC FUNCTIONS --------------------------------------------

-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
	tell mReturn(f)
		set lng to length of xs
		set lst to {}
		repeat with i from 1 to lng
			set end of lst to |λ|(item i of xs, i, xs)
		end repeat
		return lst
	end tell
end map

-- Lift 2nd class handler function into 1st class script wrapper 
-- mReturn :: Handler -> Script
on mReturn(f)
	if class of f is script then
		f
	else
		script
			property |λ| : f
		end script
	end if
end mReturn

-- filter :: (a -> Bool) -> [a] -> [a]
on filter(f, xs)
	tell mReturn(f)
		set lst to {}
		set lng to length of xs
		repeat with i from 1 to lng
			set v to item i of xs
			if |λ|(v, i, xs) then set end of lst to v
		end repeat
		return lst
	end tell
end filter

nope, this this converts the child note into a row but gets rid of

pre-scripmy scopepost-scriptits parent row

I am trying to accomplish Left to Middle pic but I get Left to right result

Ok, I see what you want to do in the screenshots. I updated the code. Current version: V0.03.
I think it’s going to accomplish your goal.

1 Like

So sorry for getting back to you just now; haven’t had a chance to test up until now. It works brilliantly, I seriously cannot thank you enough. I wish I knew scripting!!!

1 Like

You’re welcome, @stanblues999. Glad I could help.

2 Likes

Here’s a script in Omni Automation code that will add a following row using the contents of a selected row:

items = document.editors[0].selection.items
items.forEach(function(item){
	itemNote = item.note
	itemParent = item.parent
	itemParent.addChild(
		item.after,
		function(row){
			row.topic = itemNote
		}
	)
	item.note = ""
})

Sal,

I just saw this. This is brilliant as well, thanks mate.