Can someone create a "split and title" script

I tried a while ago to create a simple AppleScript to do a repetitive task that I’d like to see built in, but that Eric is reluctant to build into the program (not a criticism. I understand priorities and a reluctance to build every little request into the program — in fact warned against it.) I couldn’t seem to do it, and it seems to me that every writer needs it.

So, I’m wondering if someone can help me out:

Very simple, two actions.

Circumstances (in case someone has a better solution to my proposed actions):

I get a brainstorm and create a list, dumping a bunch of words into an RTF note in DT. Now that I have my list (let’s call them topics), each on a separate line, I want to break it into separate notes, so I can write about each topic.

Presently, I position the cursor at the beginning of the second line and click Edit > Split (for which I’ve created a keystroke combination). That creates a second document titled [title of first doc 2], switches focus to it. I the position the cursor at the beginning of the second topic in the new document, and do the same thing, for the entire list. Now I have a bunch of documents, the last one is titled [title of first document 2 2 2 2 2 2 2…n]. Now I have to go to each document and select the first line, right click (there’s no menu item, which is why I can’t create a keystroke shortcut] and click “Set title as.”

What I want is a simple AppleScript, that I can create a keystroke shortcut for, that does the above for each line (topic) of my list, or the first sentence, if I’ve written a parapraph.

Maybe also a related script that captures the selected text, splits at the beginning of the selection and sets the title to the selected text. (Scrivener has this, and it’s very useful.)

META IDEA: I think I remember a proposed script exchange for just such requests. Was that ever implemented?

Thanks much!

A simple script could look like this:


tell application id "com.devon-technologies.thinkpro2"
	set theGroup to current group
	tell text of think window 1
		repeat with thePara in the paragraphs
			set theContent to thePara as string
			if length of theContent is greater than 1 then create record with {name:theContent, content:theContent, type:rtf} in theGroup
		end repeat
	end tell
end tell

Very much appreciated. I’ll try soon.

I also find this very useful. Thanks.

Finally got to try the script above. Worked like a charm!!

Christian, thank you SO MUCH!!!

This really saves me a lot of time.

+1
Very nice; and good foundation for many other useful scripts.

I slightly modified the script so that it can be used for bulk export from Bookends (now that we no longer have usable sheets). It parses the references and names each using the UID of the Bookends reference.
In Bookends create and use an export format such as ```

bookends://sonnysoftware.com/@∆a∆j∆t∆d∆b∆PMID:u4∆

. Select the references you would like to export and copy them formatted (command-K). Paste the resulting file in DTP as a text file. Run the following script:
tell application id “com.devon-technologies.thinkpro2”
set theGroup to current group
tell text of think window 1
repeat with thePara in the paragraphs
set theContent to thePara as string
if length of theContent is greater than 1 then create record with {name:third word of theContent, content:theContent, type:txt} in theGroup
end repeat
end tell
end tell

For some reason the script fails when trying to parse more than 1,000 references at a time.

so you’re also missing the “see also” feature for finding single records in a shee?
:frowning:

I created a similar solution for my BibTeX database with a shell script splitting the whole database in a text file for each record (>2700) which is named as the citekey, so that I can easily identify it (and as a relation to the pdf file which has the same name).
All those 2700 text files are stored in a folder which is indexed by DTPro, so that I can use see also to find related literature, also if there is no full text pdf available but only the bibliographic information with abtract (or sometimes without).