I have a way to automatically grab markdown files of articles I bookmark with pinboard using Brett Terpstra’s Heckyesmarkdown.com and ifttt.com. This let’s me clip articles from the iPad, and they’re waiting for me in devonthink. It’s the slickest way I’ve been able to come with to clip from iOS.
The result is an indexed folder with markdown files. I’m trying to create a triggered script that will convert the md files to rtf (archival purposes, images are lost in md files if the site goes away). I want it to do exactly what the ‘convert > to rich text’ does, but in a triggered script.
Here’s what I have so far:
on triggered(theRecord)
try
tell application id "com.devon-technologies.thinkpro2"
set theSelection to the children of theRecord
repeat with thisItem in theSelection
if the kind of thisItem is "Markdown" then
convert thisItem to rich
end if
end repeat
end tell
end try
end triggered
You were most of the way there – just missing a term: convert record thisItem to rich
on triggered(theRecord)
try
tell application id "DNtp"
set theSelection to the children of theRecord
repeat with thisItem in theSelection
if the kind of thisItem is "Markdown" then
convert record thisItem to rich
end if
end repeat
end tell
end try
end triggered
Note: using DEVONthink’s four character identifier in “tell” statements is a way to future-proof your scripts. Also, if I were using this, either add a test to avoid duplicates, or be sure to copy everything out of the folder immediately after triggering this script. Otherwise, every time it is triggered you will get another copy of the rich text document. Ground hog day
For completeness, it would be interesting for other readers if you’d post the final version – as well as explain your “way to automatically grab markdown files of articles I bookmark with pinboard using Brett Terpstra’s Heckyesmarkdown.com and ifttt.com.”
Absolutely!
The web clipping process is a little involved, but I’ve been meaning to give a little walkthrough. I’ll create a separate topic in the next couple days.
Here’s the finalized version of this script:
on triggered(theRecord)
try
tell application id "DNtp"
set theSelection to the children of theRecord
repeat with thisItem in theSelection
if the kind of thisItem is "Markdown" then
convert record thisItem to rich
set theDestination to (display group selector "Select a Destination")
move record thisItem to theDestination
end if
end repeat
end tell
end try
end triggered
It asks for a destination for each file, but it remembers your setting, so you can just hit enter to go through all the files to be moved. There could be a better way, but works fine.
Note: if anyone uses this the same way I do, you’ll want to exclude the original MD files from search so you don’t get duplicate results. Alternatively, go through and delete the original MD files (or move them out of DT) if you don’t have any use for them.