How to Convert URL lists to Safari Bookmark
While I was working with Raspberry Pi projects, one notable trend which became prevalent was the web UI open source dockers started offering. With the proper DB, the indexing could not be faster than my handy work from 2000s. What that also meant was I ended up with a list of URLs I would want to keep on Safari.
The prerequisite is following. I had a text file full of URL, separated by a new line. It would look like this:
http://example.org
http://example2.org
I would assume Safari can simply import the list, as I was able to on Firefox — I use both for troubleshooting. Safari somehow does not support it. It only supports .html, so it needs to be converted over. On Terminal, run the following command with the paths in [source] (in .txt) and [destination] (in .html) replaced.
awk 'BEGIN\{print "<!DOCTYPE NETSCAPE-Bookmark-file-1>~<TITLE>~Bookmarks~</TITLE>~~<H1>~Bookmarks~</H1>~~<DL>~~<p>~"} \{print "~<DT>~~<A HREF=\""$0"\">~"$0"~</A>~"}' [source] > [destination]
This is my example of how I ran it:
awk 'BEGIN\{print "<!DOCTYPE NETSCAPE-Bookmark-file-1>~<TITLE>~Bookmarks~</TITLE>~~<H1>~Bookmarks~</H1>~~<DL>~~<p>~"} \{print "~<DT>~~<A HREF=\""$0"\">~"$0"~</A>~"}' \~/Downloads/bookmarks.txt > \~/Desktop/bookmarks.html
Afterward, Safari can import the .html file directly. The option is in File > Import Browsing Data from File or Folder.
Apparently this is a feature from importing Netscape era. Not that I have ever used Netscape before, but I found it simply bizarre how Safari is still supporting migration from Netscape but not plain text.

Comments will be automatically closed after 30 days.