Applescript to lock RTF files upon index

Hello, I’m afraid I’m a complete applescript novice, otherwise I’d have tried to do this myself, but…

I regularly index RTF files created in Word in DT Pro, so I can search and view them. I don’t want to edit or even click into the documents in DTP, as when I do so, word’s bullet-point formatting gets messed up (and I need to go back to the documents in Word). So I lock newly-indexed documents. But I often forget to do this, and it seems like an additional workflow step that could be dispensed with if I had the scripting know-how.

Can anyone suggest an applescript to get DTP to automatically lock newly-indexed RTFs? I’d prefer it not to lock all newly-indexed files as I have notes in plain-text I’d like to be able to edit. However, I’d be willing to have DTP lock all newly-indexed files rather than only RTFs if that’s the only way to do it.

Many thanks in advance for any help.

You could either use a smart group like…

Kind is rich text
Instance is indexed
Locking is off

…and lock its results on your own or run a simple script like this one to lock all indexed and not yet locked rich texts of your database:


tell application "DEVONthink Pro"
	set theUnlockedRichTexts to every content of current database whose type is rtf and locking is false and indexed is true
	repeat with theRichText in theUnlockedRichTexts
		set locking of theRichText to true
	end repeat
end tell

Great! Thank you!

Have you considered saving copies of your Word docs as PDFs rather than RTFs? I formerly saved Word to RTF, but for the shortcomings you mentioned and the need for the workaround you described. Now, as a matter of course, I keep PDFs of important documents instead. The added benefit, for me, is that I can annotate those PDFs when I wish, without messing with review & comment in Word.

I had thought about doing that, but as these docs consist of pages and pages of notes on articles and books that I often want to pare down later, it seemed easier to keep them in .rtf. If only word’s stupid bullet point formatting was compatible with other OSX apps this wouldn’t be a problem…

More broadly, dependency on Word is something I’d like to kick, but after extensively customising the interface (i.e. hiding the ribbon, everything from toolbars and menus I didn’t need) and keyboard shortcuts, I’ve actually found it to be a useful (and efficient) app for taking long, structured notes (anywhere between 5 and 50 pages) on single texts. E.g. automatic creation of a document map based on heading styles, easy mapping of styles (headings, bullet points, numbering). excellent autocorrect/spelling & grammar correction. Only just makes up for all its other problems and lack of integration with OSX, but still.