places2bookmarks

places2bookmarks is a shell script for converting places.sqlite to bookmarks.html.

This is neccessary because through an oversight of stupendous proportions, Mozilla (firefox, iceweasel etc.) is unable to import bookmarks from its own internal format.

If you have a copy of a ~/.mozilla directory from Firefox 3 or later, you will find a database file called .mozilla/blahblah/places.sqlite (where blahblah is some gobledegook which identifies your profile).  This file contains your history and bookmarks.  If you install the program sqlite3, you can use the following script to convert the bookmarks into html format, so that the very same version of firefox (or almost any other browser) can import them.

Requirements

Download

http://www.purposeful.co.uk/software/places2bookmarks/places2bookmarks.sh

Usage

places2bookmarks.sh ~/.mozilla/firefox/l9aenv7l.default/places.sqlite >bookmarks.html

Licence

This is truly free software.

Source

#! /bin/bash
# PUBLIC DOMAIN
# See http://www.purposeful.co.uk/software/places2bookmarks/

IFS=$'\t\n'

conv(){  
  echo "$3<DL><p>"
  sqlite3 -separator $'\t' "$1" "select moz_bookmarks.id, type, moz_bookmarks.title, url from moz_bookmarks left join moz_places on moz_bookmarks.fk=moz_places.id where parent=$2 and type in (1,2,3) order by position" | sed 's/&/\&amp;/g;s/"/\&quot;/g;s/</\&lt;/g' | while read -r id type title url
  do
    if [ "$type" = 1 ]
    then
      echo "$3  <A HREF=\"$url\">$title</A>"

    elif [ "$type" = 2 ]
    then
      echo "$3  <DT><H3>$title</H3>"
      conv "$1" "$id" "$3  "

    else
      echo "$3  <HR>"
    fi
  done
  echo "$3</DL><p>"
}

echo $'<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<TITLE>Bookmarks</TITLE>\n<H1>Bookmarks</H1>'

conv "$1" 0 ''