Exporting bookmarks

After iCloud helpfully synchronized my Safari bookmarks with an old backup, I wound up with multiple copies of every bookmark. So I cleverly imported them to DTPO and let it find all the duplicates. Now, after deleting the duplicates, I want to export the bookmarks back to Safari. But how?

Safari will only import an HTML file with a simple list of links. (If you use File>Export Bookmarks… in Safari, you will see the format it needs for importing.) It will not import a Table of Contents, because that is entirely DT x-links. It will not import a folder full of webloc files. It will not import an OPML, which is the only way I can export a list of HTML links.

I have searched the help documentation and the forum without success. Is there maybe a way to script this?

PS Here is a sample of the file I need from DTPO:

<!DOCTYPE NETSCAPE-Bookmark-file-1>
	<HTML>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
	<Title>Bookmarks</Title>
	<H1>Bookmarks</H1>
	<DT><H3 FOLDED>Favorites</H3>
	<DL><p>
		<DT><A HREF="https://read.amazon.com/">Kindle Cloud Reader</A>
		<DT><A HREF="https://www.filemaker.com/help/14/fmp/en/">FMP 14 Help </A>
		<DT><H3 FOLDED>Genealogy</H3>
		<DL><p>
			<DT><A HREF="http://trees.ancestry.com/tree/33384482/family">Ancestry.com</A>
			<DT><A HREF="https://familysearch.org/learn/wiki/en/Family_History_Library">Family History Library</A>

And so on…

1 Like

What you’ve posted isn’t complete enough to match, as it’s composed of nested definition lists. If you have a raw list of Bookmark files in DEVONthink, it’s possible to script generating the links in HTML format but not Bookmarks groups, like “Genealogy”.

As you say, after the header this is simply a nested list of folders (groups) and bookmark links. The folder template I need looks like this: ```

Folder Title

{{link lines and subordinate folders}}

```and the bookmark link lines look like this: ```

Link Title

In comparison, if I export an OPML file, I get exactly the same pattern of nested list. The folders look like this:

{{link lines and subordinate folders}}

1 Like

I’d like to see your code on that.

Scripting it to create a valid Bookmark file is pretty trivial. My point was, if you just have a ton of loose Bookmarks, there would be no H3 folder information to process. So you would have a valid Bookmarks file but they wouldn’t be in groups.

1 Like