Poking around firefox's bookmarks store: places.sqlite

Today I wanted to retrieve some bookmarks that I made the other day on my home computer, from far away. Thankfully I can access my pooter over SSH, allowing me to poke around inside it on the command line.

Older versions of firefox stored bookmarks in XML files, which made it easy to rifle through them on the shell. Newfangled firefox uses sqlite files however, which makes accessing this data a bit harder.

Here’s some quick commands you can run to extract your precious URLs from firefox’s places.sqlite file.

You’ll need sqlite3:

sudo apt-get install sqlite3

First, cd into your firefox profile dir, where the places.sqlite file resides:

cd ~/.mozilla/firefox/*default/

To gain a list of all bookmark folders in this profile, do this:

sqlite3 places.sqlite "select id,title from moz_bookmarks where type=2"

Choose the folder whose URLs you want to list, noting its ID from the left column of the output from above . Use this ID in the next query instead of 92363:

IDS=$( sqlite3 places.sqlite "select fk from moz_bookmarks where parent=92363" )

Finally, get the URL associated with each ID:

for i in $IDS ; do sqlite3 places.sqlite "select url from moz_places where id=$i" ; done

Now you should have a neat list of URLs. These can be opened in firefox by simply specifying them as arguments on the command line. (So add firefox $( ... ) around the previous command).

Here’s how it looked for me:

  1. id@hms-borange:~$ cd ~/.mozilla/firefox/*default
  2. id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ sqlite3 places.sqlite "select id,title from moz_bookmarks where type=2"1|
  3. 2|Bookmarks Menu
  4. 3|Bookmarks Toolbar
  5. 4|Tags
  6. 5|Unsorted Bookmarks
  7. 12|Latest Headlines
  8. 15|Ubuntu and Free Software links
  9. 22|Mozilla Firefox
  10. 67|
  11. 70|All Bookmarks
  12. 194|e-dribble
  13. 2024|JOBS
  14. 3026|Nedroid Picture Diary
  15. 36522|The Register
  16. 49621|jubs
  17. 92363|maemoo
  18. id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ IDS=$( sqlite3 places.sqlite "select fk from moz_bookmarks where parent=92363" )
  19. id@hms-borange:~/.mozilla/firefox/19xwzg4w.default$ for i in $IDS ; do sqlite3 places.sqlite "select url from moz_places where id=$i" ; done
  20. http://maemo.org/maemo_release_documentation/maemo4.1.x/node4.html#SECTION00432000000000000000
  21. http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/Maemo/
  22. http://maemo.org/development/sdks/maemo_2-2-gregale/
  23. http://maemo.org/development/documentation/tutorials/Maemo_2_2_Tutorial/#settingup
  24. http://scratchbox.org/download/scratchbox-apophis/
  25. http://repository.maemo.org/stable/gregale/
  26. http://repository.maemo.org/stable/gregale/i386/
  27. http://repository.maemo.org/stable/gregale/armel/
  28.  

No comments

Post a comment


Name:  
Remember personal info?

Email:
URL:
Comment: Emoticons / Textile

This is not a trick question, but a mechanism for spam prevention.
 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Powered by Pivot. RSS Feed & ATOM Feed