Convert Rows to Notes

I came here to ask if there is a shortcut to convert the text in a row to a note, but I see that has been asked and answered negatively. I have imported a lengthy document and there are many rows I would like to see as notes. Cut and paste and adding to notes is quite tedious, and if the entire row, not just the text is selected, the process fail. Can this be scripted?

Yes, it can be scripted. Make a copy of your document, first.
Does this solve your problem?

tell application "OmniOutliner"
	tell front document
		set listRows to selected rows
		repeat with i from 1 to (count listRows)
			set note of (item i of listRows) to topic of (item i of listRows)
			set topic of (item i of listRows) to ""
		end repeat
	end tell
end tell

Thank you - this is a big improvement over cut and paste. Ultimately I’d like the note that started as a child row added to the parent and not added as a note on that child. At some point I need to learn to script Omni products, and not rely on the kindness of strangers.

You’re welcome. I’m in a trip without my Mac. You can post a screenshot of your desired outcome and, when I come back, give you some help.

Here’s what I started with:

After running the script I have this (better):

Perfect would be this:

Very clear explanation.
I think it’s possible but I can’t test it without my Mac. When I come back, I will write the code.

Perhaps also worth defining what you would like a script to do when any of the selected rows (destined to be subsumed within a parental note) happen to have their own descendants.

And also, of course, to what extent you need to preserve meta elements like emphases and inline links (i.e. Markdown level formatting) or even full Rich Text formatting (fonts, sizes, colours and the rest).

I achieved what you’re looking for with a Keyboard Maestro workflow a whole back, Highly recommend if you don’t already have it.

I appreciate all the feedback on this.

Let’s say I have an outline

  1. Parent
    A. child
    B. child
    C. child
    D. child

Nomadwino, I tried the macro you set up. If I select D., it becomes a note attached to C. When I use unlocked2412’s script, D. becomes a note attached and empty row formerly known as D. Ideally I would like to select D and have it become a note attached to 1.

Draft8, my current use would not be for outlines that are more that two levels deep. I am not sure if I would ever apply it to a level higher than the lowest level of the outline. I am not sure how I would want that situation handled. Is there a “best practice” for this? Since these are plain text outlines formatting isn’t relevant.

Thanks to all of you. I might be learning something here.

Ah right, Well that’s ok, just need to add a couple more arrow keys in there…

Tried it & gives me:

That does it. Thank you. I guess I need to spend some more time with Keyboard Maestro.

I am back from my trip. This solution is pure Applescript. With this script you can select multiple rows. I think it’s an advantage.
Could you try it, @ThosWolfe? Tell me if it solves your problem. Any suggestions are welcomed.


tell application "OmniOutliner"    
	tell front document    
		set listIDs to id of selected rows    
		repeat with i in listIDs    
			set theRow to row id i    
			if not (exists ancestors of theRow) then    
				display dialog "The selected row doesn't have any parents."    
				if (exists children of theRow) or (note of theRow ≠ "") then    
						set dialogAnswer to (display dialog "This row has children and/or notes. What do you want to copy into parent's note?" buttons {"Cancel", "All", "Only selected row"} default button 3 cancel button 1)    
						if button returned of dialogAnswer is "Only selected row" then    
							set textNote to topic of theRow    
							pbcopy items theRow    
							set textNote to the clipboard    
						end if    
					on error number -128    
						display dialog "Operation Canceled"    
					end try    
					set textNote to topic of theRow    
				end if    
				set note of ancestor 1 of theRow to textNote    
				delete theRow    
			end if    
		end repeat    
	end tell    
end tell
1 Like

You are a bit braver than me there in the use of delete :-)

( For some reason I am always a bit wary of using deletions in code that I share )

In that particular case, I think I might want to feel sure that theRow didn’t have any children/descendants that were going to get deleted with it, imaginably to the surprise of the user.

Perhaps a check or warning, or even a way of bringing the topics and notes of any descendant tree into the parent note ?

Based on draft8 advice, I updated the code. Now, it covers a wider rage of use cases.

1 Like

The script is great. It does exactly what I wanted, plus it works on multiple rows, as you said. This will save me tons of time.

I don’t know what I am missing but when I can’t convert multiple highlighted rows (even if done individually) to the same amount of notes. this is the result I always get: