Import Bookmarks from CSV file with custom metadata

Hello guys,

I’m just trying Devonthink out and I’m not technically savvy enough to import bookmarks from a .csv with the following structure while keeping the custom metadata intact:

Title | URL | Date | Author
Doktor Schiwago | .com | 31.12.2011 | Boris Paternak
Krieg und Frieden | .com | 31.12.1869 | Leo Tolstoy

Could anyone please help me out with an example script?

I don’t see any bookmarks there, only top-level domains. Also, what do you mean by „import“ here? A script would have to create these bookmarks, I suppose.

Thanks for answering.

You are right.
I had to leave the rest out because the spamfilter wouldn’t let me post it.
By importing I do mean to create them in Devonthink, I exported the .csv from MyInfo.

For clarity and practical testing, there are always two requirements:

  1. An actual sample of input – perhaps you could zip a sample of such CSV and attach it here ?
  2. Clarity about the corresponding output – perhaps you could manually create a sample of 2 or 3 corresponding bookmarks in DEVONthink, and show a screenshot of them here ?
1 Like

Thanks for looking into it.
The original has about 500 entries, so it would be tedious to do this manually.

Here are the examples: (937 Bytes)

1 Like

What custom metadata are you referring to? There is no such thing in a .CSV file from an external source.

Also, importing a .CSV file yields a DEVONthink sheet, fully intact as it was exported. Here’s yours…

And here, I’ve edited the column headers…

…and removed extraneous records…

1 Like

Thanks for helping.

Sorry, English isn’t my first language.
It is difficult to to explain what I’m trying to achieve.

The .csv is an export from a different programm i use. Every row is a separate note there.
So I don’t intend to import the .csv directly into DEVONthink.

I am trying to display the data inside of it as bookmarks in DEVONthink.
Every row should be a bookmark there.

With custom metadata i mean the data in the last two columns.
I created entries corresponding to the last two headers (Creator and Date) under Settings/Data in DEVONthink.

Like this:

1 Like

If I understand you correctly, this should do what you are asking for:

(() => {
  const app = Application("DEVONthink 3");
  /* Change for your UUID form 'Copy link' context menu */
  const rec = app.getRecordWithUuid('2B03F688-7808-4598-91B7-72FAB0CC1E30');
  /* Change name of database and group for the bookmarks */
  const targetGroup = app.createLocation("/Bücher", {in: app.databases["Test"]});
  const cells = rec.cells();
  cells.forEach(row => {
    const title = row[0];
    const URL = row[1];
    const author = row[2];
    const date = new Date(row[3]);
    const newRec = app.createRecordWith({name: title, type:"bookmark", URL: URL, creationDate: date}, {in: targetGroup});
    app.addCustomMetaData(author, {for: "Creator", to: newRec})

The code works with a pre-defined record, using the UUID from ‘Copy Link’. You must change that to reflect the UUID of your CSV file. Also, it creates all bookmarks in the group “Bücher” in database “Test” – adjust both of these names to your liking.

You can run the code from Script Editor (copy/paste it there) after having set its language selector to JavaScript. Alternatively, add it to DT’s scripting folder (see the manual for that) and then run it from DT’s script menu.

BTW: If English isn’t your first language, why are you using the English Wikipedia references?

2nd BTW: I’m not sure what you’re after here. Storing names of people as “firstname lastname” fields is not the best way to go about that if you want to search for them etc. Actually, a table is known to be a bad caricature of a relational database. If you really intend to use plenty of books and authors, you should think about another approach.

1 Like