Copy DEVONthink records as TSV for pasting to Tinderbox (script)

Update: Aug 21, 2017 – the date handling was broken in some cases. The current link should fix that.

The AppleScript found at this link will put information about records in your DEVONthink database onto the clipboard. When you paste that clipboard into a Tinderbox view (Outline works best), each line on the clipboard is pasted into Tinderbox as a new note.


USE:

Select one or more records (“documents”) that are not groups in a DEVONthink database. Run the script. In Tinderbox 7.x open a document on an Outline or Map view. Paste the clipboard.

The intended result is a series of notes – one for each DEVONthink record copied by the script.

The rationale for this script, in addition to the already-supported dragging from DEVONthink to Tinderbox, is that this script adds data to the import that dragging from DEVONthink does not provide, especially the DEVONthink Created and Modification dates. (See below.) The script is also extensible – users can modify it to add other data from DEVONthink such as Labels, Spotlight Comments, and Read/Unread flags, etc.


FEATURES:

The Tinderbox document must have a User attribute $SourceURL, defined as type==URL, before or after the import, so that the URL is an active, clickable URL linking you back to the original source of the information. E.g., the web page from which you clipped content and added to your DEVONthink database.

Attributes whose values not defined in your DEVONthink database have no value assigned in Tinderbox. The $URL attribute is the x-devonthink-item:// reference URL for the record in your database.

The new notes have the $AutoFetch attribute included, so by clicking that attribute’s checkbox you can request Tinderbox to fetch the contents of that note’s info from the corresponding record in DEVONthink.

The new notes also contain the created and modified dates from the original DEVONthink record which are stored in User attributes $SourceCreated and $SourceModified that are created at the time you paste the data.


SOURCE:

https://d.pr/f/fsjPmB+

Download the .zip. Open the .scpt file in Script Editor or Script Debugger, or other. Compile. Save where you wish. A good destination for saving is in the ~/Library/Application Support/DEVONthink Pro 2/Scripts folder, in a subfolder you create for your private scripts. When saved there, the script will appear in DEVONthink’s Scripts menu and will not be overwritten when you update DEVONthink.

For script editors: the file contains numerous tab characters that appear in Script Editor as blanks enclosed in quote marks. Be careful. Removing any tab characters will break the script.

1 Like

The ability of Tinderbox to recognize pasted text from the clipboard as TSV is very useful for script writing. We can do similar AppleScripts, or JXA scripts, that place data from other programs on the clipboard, without the additional effort to save the data to a file then import the file.

Awesome!! Thank you SO MUCH for this! I had been planning an agent which looks at the $URL, passes it to an Applescript via runCommand() and loads the info… your approach is WAY simpler and better!

Somewhere along the way, Tinderbox stopped auto-fetching the note content on import. Here are a couple agents you can use to fetch the content. I have them looking inside a note called INBOX, but you could change that or do it as a stamp.

Fetch DEVONthink content

// $AgentQuery
inside("/INBOX") & $URL.beginsWith("x-devonthink-item://") & !$Text

// $AgentAction
$AutoFetch = true;

Unset AutoFetch on fetched DEVONthink notes

// $AgentQuery
inside("/INBOX") & $URL.beginsWith("x-devonthink-item://") & $Text & $AutoFetch

// $AgentAction
$AutoFetch = ;

Dear Paul Walters,

Terrific!
Thanks a lot for your information and guidance!
I am a person who favors DEVONthinkPro as a longtime 17years.
I have saved it in the ~/Library/Application Support/DEVONthink Pro 2/Scripts folder.
Now, I can use much-valued behavior with DEVONthink and Tinderbox.

Sorry, that is a stupid thing to ask.
With Tinderbox, entry-level and apple knocker myself.
I am inexperienced in TSV.
This conversation piece teach me a good lesson.

Each line on the clipboard is pasted into Tinderbox as a new note.

BTW, How can I change Tinderbox’s Note Name automatically switch from
“imported spreadsheet” to (EG “quoted from DEVONthink”) ?

I would greatly appreciate your assistance or advice regarding.

Yours, WAKAMATSU

Thank you ever so much, @PaulWalters

However, the dates populating $SourceCreated and $SourceModified are sort of randomly created … at least do they not equal those dates brought over from Devonthink via Clipboard.

Here’s an image of how it looks here:

I don’t believe you can change this. When a CSV or TSV text is pasted this “imported spreadsheet” is always the container that Tinderbox creates. I usually move the children of that container (the actual imported notes) to some other place in the document and then deleted the left-over “imported spreadsheet” note.

@pat, @WAKAMATSU, @andreas

The date handling was broken in some cases due to the way DEVONthink formats the date string, which is not always compatible with Tinderbox’s date parsing. The link in the OP above, or below, should fix that for you.

https://d.pr/f/fsjPmB+

If there are additional issues I will withdraw this post, since I won’t have time to code corrections until September.

Just two minutes ago I updated the image in hope to clarify my question … and then, again, @PaulWalters just pops up with a solution. Thank you very much, @PaulWalters. Now the scripts seems to work perfectly well.

1 Like

Dear Paul Walters,

Thanks a lot for your redaction.

I would like to notice something different from usual about “imported spreadsheet” .

If I use your script, could not I update in my “imported spreadsheet” note ?

How can I get new matters to bring together in the same “imported spreadsheet” note ??
( I do not want to litter and getting different kind of “imported spreadsheet” notes in my Tinderbox. )

Please give me a piece of advice.

(But, I do not want to put you to trouble or caught in the cross-fire.)

Yours, WAKAMATSU

The script provides a result similar to the existing Tinderbox feature for dragging documents from DEVONthink to Tinderbox. The “x-devonthink-item” link for each document is put into $URL and the $AutoFetch boolean is shown in the Key Attributes for the imported note. So, click the box next to $AutoFetch and the content of your DEVONthink note will be updated to reflect changes in the source document in DEVONthink. (See more about AutoFetch in Help and at aTbRef.)

Just select new / different notes in DEVONthink and import them separately. As I said above, you can move your notes around your Tinderbox document wherever you want them. You do not need to leave the notes inside the “imported spreadsheet” container. The rest is up to you.

Dear Paul Walters,

Your feedback is greatly appreciated.

I will put your script to the test, again,
thank you for your help with this matter.

Yours, WAKAMATSU

This could be the breakthrough I was hoping for! The script does work very well.
While Simplenote has been working a little better than it had been in previous versions, I still find it limiting.
Devonthink has an app that I can use to collect my tasks and information with a very easy way to transfer the information to Tinderbox. The only thing is that there is still no way to synchronize.
My question is: am I just adding another program that has to be updated all the time - so more work for me.
I had tried using Devonthink as my Task manager and it works well on the iphone, so I could use it as my inbox gatherer, but how to transfer Tinderbox’s organization?

What I mean by Tinderbox’s organization is basically the agents

DEVONthink does not have a feature like Agents – other than smart groups, which are rather ignorant little beasts when compared to what Tinderbox does with agents.

DEVONthink To Go does not (yet) have much in that area.

For now you would have to hand-hack the hierarchy in DEVONthink to correspond to Tinderbox’s.

Two years later, still works.

I have 2 basic questions:

  1. when I paste into Tinderbox, a note titled “imported spreadsheet” is generated within which the note containing clipboard data is placed. Is there a way to eliminate the hierarchical pasting, i.e., paste without the “imported spreadsheet” note.

  2. is TBX scriptable? I’m wondering if the script can be modified to paste the clipboard content into a pre-specified container in TBX.

Thanks.

Neither of these is easy now.

The container note is often convenient, and avoids all sorts of problems when pasting into maps. It’s not very hard to promote the imported notes if you don’t want the container.

Tinderbox has very, very limited scripting support. But something like this could be added, if there’s urgent need.

I confirm what @eastgate says about the “imported spreadsheet” container. It’s easy to move things out of it, and having that container has saved me a lot of grief over the years. It’s more a safety net than a hindrance.