In this recent posting - Split and Title - Christian submitted a script in response to a request by grsilverman, who wants to explode a note at paragraph boundaries into separate notes.
For example, this could be very useful for breaking an annotation into new documents.
The script that follows takes the concept a step further by: exploding the note, numbering the exploded pieces (so that the sequence of the original can be maintained), putting the exploded pieces into their own group, placing the custom url (“item link” in DT parlance) of that group into the URL field of the original note, and placing the custom url of the original note into the URL fields of the exploded pieces. Thus allowing easy access.
Here’s one use case: explode a note. Open the note in 3 pane view. Cmd-click the URL for the source note, causing the exploded-note group to load into a tab, set View preference to “Show Details”. You’ll get a nice listing of the note names in the new tab, in which you can use quick look to view the contents of each note.
This is also possibly helpful for those who need to have multiple annotations for a document. (Drat, can’t find that thread right now - help sjk!)
-- Explode a document into multiple documents
-- Place the exploded pieces into a group
-- Link the original (unexploded) document to that group
-- Based on a submission from Christian in the scripting portion of the DT Forum 20100407
-- at http://www.devon-technologies.com/scripts/userforum/viewtopic.php?f=20&t=10676#p49988
-- a kormic creation
tell application id "com.devon-technologies.thinkpro2"
set theDatabase to current database
set theGroup to current group
set theseItems to the selection
if selection is {} then error "Please select some contents"
tell text of think window 1
set paranum to 1
repeat with thisItem in theseItems
set selectionURL to (("x-devonthink-item://" & uuid of thisItem) as string)
set targetGroupName to "/Exploded:" & (name of thisItem as string)
set targetGroup to create location targetGroupName in theDatabase
set targetGroupURL to ("x-devonthink-item://" & uuid of targetGroup)
set URL of thisItem to targetGroupURL
repeat with thePara in the paragraphs
set theContent to thePara as string
if length of theContent is greater than 1 then
set txtLength to (length of theContent)
if txtLength < 45 then
set theName to (paranum & ": " & (texts 1 through txtLength of theContent) as string)
else
set theName to (paranum & ": " & (texts 1 through 45 of theContent) & "..." as string)
end if
create record with {name:theName, content:theContent, URL:selectionURL, type:rtf} in targetGroup
set paranum to paranum + 1
end if
end repeat
end repeat
end tell
end tell
Example of the use case: