How To Convert Firefox Bookmark Dates Using Groovy/Java

Firefox offers us two ways to keep our bookmarks, 1: backup as a json formatted file or 2: export as an html file.

This tip is for the json backup crowd 🙂

When we backup our bookmarks from Firefox, they come out formatted as json. The dates found therein are stored in what’s known as epoch dates ( read this ) though include millesecond precision – meaning 1,000 trailing milliseconds. So, for example, the firefox bookmark lastModified date of  1366313580447014 is really just 1366313580447. So when we write code, we divide by 1,000 to remove that part. My groovy code sample seemed to work when it looked like this :

def convertDate(def epoch)
{
     long dv = epoch / 1000; // divide by 1,000 to avoid milliseconds 
     String dt = new java.text.SimpleDateFormat("dd/MMM/yyyy HH:mm:ss").format(new java.util.Date (dv)); 
     // to get epoch date: 
     // long epoch = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 01:00:00").getTime() * 1000; 
     return dt; 
} // end of def

So for a test sample, i did a firefox backup to get bookmarks-2013-04-29.json. Then added some groovy sugar to parse the text with json slurper.

json.lastModified :1366313580447014
convert from epoch date:18/Apr/2013 21:33:00

from :
println “convert from epoch date:”+convertDate(json.lastModified)

TenFourFox (aka Firefox) V20.0 ready for Apple iMac PPC’s G3,G4 & G5

The staff at Floodgap Software have worked overtime to keep us older Apple iMac people happy by reworking the Mozilla source code for Firefox. This allows them to produce a version of this famous browser for the PowerPC chipsets found in older Apple iMac, Powerbooks, etc. Supported chipsets include G3, G4 and G5 processors. You can look at their Floodgap Intro Page here: http://www.floodgap.com/software/tenfourfox/

Grab a download of the TenFourFox Version (Firefox) for your iMac PowerPC Chipset system here: http://code.google.com/p/tenfourfox/downloads/list. You will need to know which processor your system has.

The release notes can be found here : http://code.google.com/p/tenfourfox/wiki/ReleaseNotes200

Developer notes can be found here: http://tenfourfox.blogspot.fr/

Import Bookmarks from Other Browsers Using Opera 12

While doing a review of my previous posts, it looks like many of you are interested in the import and export of bookmarks between browsers of differing persuasions. Read this if you need to know more about bookmarking in Firefox. This post covers the same ‘how to’ for the Opera web browser.

This version of Opera
This version of Opera

Next, assuming you are using this version of Opera, look at the menu bar at the top of your screen. Find the BOOKMARKS menu option and click that.

Take the MANAGE BOOKMARKS option
Take the MANAGE BOOKMARKS option

This choice takes us into the features of Opera where we can work with our previously stored bookmarks.

Import Bookmarks from Firefox
Import Bookmarks from Firefox

Click the FILE option, then click to import one set of bookmarks from the list of browsers shown. You may need to do this several times to harvest all the bookmarks from all your browsers.  Wait while Opera does a non-destructive copy of bookmarks from your chosen browser. At completion, you will find a new series of bookmarks have arrived in your Opera. Mine looks like this – hope your’s does too

Successful import of Firefox bookmarks
Successful import of Firefox bookmarks

Import Bookmarks from Other Browsers in Firefox 14

A feature of Firefox that i particularly like is the ability to import all my book marks from other browsers that i use. Since i often have several hundred bookmarks, it would be quite tedious to copy all those bookmarks over from my Google Chrome, Apple Safari, Opera and Internet Explorer browsers.

So to import those bookmarks into Firefox, click the Bookmarks menu option in the menu bar. It should look like this :

Click Bookmarks menu option
Click Bookmarks menu option

and the Show All Bookmarks menu option should be clicked. This will open the Library panel where we can manage our bookmarks. Because i wanted to pull in my bookmarks from other browsers, i chose to click the button that looks like a star. It should look like this :

Bookmark Star Menu Option
Bookmark Star Menu Option

and from here we can click to see a panel of yet more options :

More options to handle all our bookmarks
More options to handle all our bookmarks

We have a number of choices here. We can choose to Import bookmarks from an external file encoded as html. We can Export all our Firefox bookmarks into an external file encoded in html, perhaps to send to someone or load into another browser. We can Backup all our bookmarks into an external file that can later be used to Restore if our bookmarks are lost or blitzed. Did i tell you that Firefox now automatically makes a copy of it’s bookmarks at the start of each day that you use it ? Click Restore to view a list of prior day’s automatic backups we can restore from. Days may appear to be missing because if we did not use Firefox, then it will not have made a bookmark backup.

Prior automatic backup copies of Firefox bookmarks
Prior automatic backup copies of Firefox bookmarks

My purpose this time is to take in bookmarks from another brower, so I click Import Data from Another Browser and should see this panel :

Choose Browser Bookmarks to copy
Choose Browser Bookmarks to copy

Click the radio button in front of the browser you want to be the donor, then click Continue. This feature will cause Firefox to look into the bookmark storage area of the browser you choose from this list and read all those bookmarks. This is a direct read from thta browser’s internal file system. Cool !  After doing that, my choice of bookmarks has been vastly increased. This pix shows how i imported both Safari and Google Chrome bookmarks.

Now, here is something i’d forgotten that i had tried some time ago – to import Firefox bookmarks into Google Chrome. That must have worked too as if we look at bottom right of this pix, we can see a folder called Imported From Firefox. 🙂   You should try it. It’s not hard 🙂

A Whole New Set of Bookmarks copied from my other browsers !
A Whole New Set of Bookmarks copied from my other browsers !

Backup / Export Bookmarks from Firefox 14

Click any screenshot pix below to enlarge.

Just loaded version 14 which looks almost the same as previous versions, even the bookmark export feature seems to be the same. I have a shed load of history and old bookmarks in all my browsers : Firefox, Safari, Google Chrome, Opera and Internet Explorer.

So i wanted to find out how to export and save all those URL’s. After much searching, found this: http://support.mozilla.org/en-US/kb/Backing-up-restoring-bookmarks. It says :


Backup and restoring

Manual backup

  1. On the menu bar, click Bookmarks and select Show All Bookmarks to open the Library window.

  2. In the Library window, click the Import and Backup button and then select Backup….
  3. In the Bookmarks backup filename window that opens, choose a location to save the file, which is named bookmarks-“date”.json by default. The desktop is usually a good spot, but any place that is easy to remember will work.
  4. Save the bookmarks json file. The Bookmarks backup filename window will close and you can close the Library window.

Here are some screenshots :To work with bookmarks, click Bookmarks in the menu. this should offer you a sub menu like this. Then click Show All Bookmarks to follow the trail to the next step.

See that button top left that looks like a Star ? Click that to open a sub-menu with options. Because the tool i’m writing can consume HTML, i clicked the Export Bookmarks To HTML choice.

Here you can see the Save As menu from my Apple.Typically, i export and import lots of stuff to my downloads folder. I know i can go back later and delete those items as they are typically short-lived. The Firefox export feature suggests a filename of bookmarks.html and as that is ok with me i click SAVE button, then run my tools over the exported HTML file.

Import Bookmarks from Other Browsers Using Firefox 13

Click any screenshot pix below to enlarge.

Just loaded version 13 which looks almost the same as previous versions. I’ve been exploring some of the latest features in this version of the venerable browser.

I’m assuming you are reading this post as you are interested in the bookmarking process of Firefox. Perhaps you have problems with your bookmarks, or want to collect all your bookmarks that you made earlier in different browsers into a single collection, or you just want to know more, so read on.

What Are Bookmarks ?

Each time you visit website pages on the internet, your browser remembers the address of those pages and keeps them in a history file. All browsers do this, not just Firefox. Using the HISTORY menu option at the top of your browser screen, you can review the web pages you’ve visited. Bookmarks are addresses that you choose to remember, or rather, to ask your browser to remember, so that you can reach them again later.

Copy Bookmarks From Other Browsers

The new version of Firefox 13.0 has a shiny new feature to copy all the bookmarks from other browsers on your computer. It does this by finding out which browsers are located on your system, and then reading the bookmarks from their bookmark respoitory. This allows a copy process to include bookmarks that you might have made while using another internet browser on the same computer.

Steps

Here is an example, i did on my Apple Mac using Firefox 13.0.

Choose Bookmark Menu Option from Firefox Menu
Choose Bookmark Menu Option from Firefox Menu

Click the BOOKMARKS option to see a choice starting with SHOW ALL BOOKMARKS. Click this to reach this display :

This is the option you need to choose.

.
Import Menu Option
Import Menu Option
Choose which browsers to copy from. Note that Firefox may not ‘see’ all the browsers on your system. On my systems it did not find my Opera or Arora web browsers but it did find Safari, Google Chrome and Internet Explorer.
Choice of Browsers To Copy Bookmarks From
Choice of Browsers To Copy Bookmarks From
You can pick which resources to copy from other browser(s). This is a non-destructive copy so you will not loose anything in the other browsers.
Choose Which Features To Copy
Choose Which Features To Copy
Successful Imports look like this. Hope yours worked ok.
Successful Import
Successful Import

Sample Bookmarks Successfully Imported – If you export as an html file now, your exported file will show the complete collection of bookmarks from your selected import browsers.

Sample Bookmarks Successfully Imported
Sample Bookmarks Successfully Imported

Hope that helps a little. 🙂

Backup / Restore Bookmarks from Firefox 13

Click any screenshot pix below to enlarge.

Just loaded version 13 which looks almost the same as previous versions. I’ve been exploring some of the latest features in this version of the venerable browser.

I wanted to find out more about the bookmark features and how to save and restore all those bookmarks. After much searching, found this: http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox.

I’m assuming you are reading this post as you are interested in the bookmarking process of Firefox. Perhaps you have problems with your bookmarks, you need to find bookmarks that you made earlier, or you just want to know more, so read on.

What Are Bookmarks ?

Each time you visit website pages on the internet, your browser remembers the address of those pages and keeps them in a history file. All browsers do this, not just Firefox. Using the HISTORY menu option at the top of your browser screen, you can review the web pages you’ve visited.

Suppose you vist a website page on knitting and want to keep the address / location of that page for future use. You can use the BOOKMARKS menu option to do that. Click that menu option to reach a smaller set of menu options, one of which is BOOKMARK THIS PAGE. If you click that option, your browser will remember the address of your current web page in a bookmark file. You may be asked to choose a folder where your bookmark will be stored. Remember that the history file and the bookmark file are different and are not stored together. They are not used for the same purpose.

Firefox Menu showing Bookmarks feature
Firefox Menu showing Bookmarks feature

You can maintain the bookmark file as you would any other file. You can add more bookmarks, you can delete them, you can move them between folders and topics.


Why ?

Often it becomes necessary to preserve your bookmarks. Perhaps you want to move your bookmarked website addresses between different versions of a browser, between different browser’s bookmark systems or even between different computer systems. With Firefox 13.0, you have two choices. You can either :

  1. Backup Bookmarks to HTML file
  2. Do a Full System Backup

Which choice depends on what you want to do, Neo.

Full System Backup

A full system backup is typically used when you wish to preserve a full copy of the existing bookmarks against future problems so you could reload them later. This is a manual task on your part to preserve your bookmarks. Firefox 13.0 has an automatic backup feature ( dunno about prior to 13.0 ) to save your bookmarks at the start of each day. The first time each day you use Firefox, it will check if a backup has been taken for today and if not, it will make a full bookmark backup copy for you so that you can restore from it later. If you do not use Firefox for a few days, or if you leave Firefox running for several days, there may not be an automatic backup for those days. This will appear as a gap in the dates of the backups.

The Backup and Restore feature uses a file format known as JSON. This is an internal format that browsers use to transport data within/between themselves and other systems. It looks a bit like this:

{"title":"","id":1,"dateAdded":1288945922841437,"lastModified":1319894108276677,"type":"text/x-moz-place-container","root":"placesRoot","children":[{"title":"Bookmarks Menu","id":2,"parent":1,"dateAdded":1288945922841813,"lastModified":1338991283571705,"type":"text/x-moz-place-container","root":"bookmarksMenuFolder","children":[{"title":"Recently Bookmarked","id":2679,"parent":2,"annos":[{"name":"Places/SmartBookmark","flags":0,"expires":4,"mimeType":null,"type":3,"value":"RecentlyBookmarked"}],"type":"text/x-moz-

Export To An HTML File

A backup to an HTML file would be used when you wish to transport your bookmarks to another system or browser, or maybe email them to Aunt June, etc. It is a full copy of all your bookmarks, you cannot choose to export just a piece of it. Beware of your bank details!

Sample Exported File in HTML
Sample Exported File in HTML

You can also view this exported file as a web page just by clicking it in your file finder / explorer tool to open it. It has a different format from JSON and is the HTML format we use to construct web pages. A sample HTML file that was exported, might look like this:

<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
     It will be read and overwritten.
     DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks Menu</H1>

<DL><p>
    <DT><A HREF="place:folder=BOOKMARKS_MENU&folder=UNFILED_BOOKMARKS&folder=TOOLBAR&sort=12&excludeQueries=1&maxResults=10&queryType=1">Recently Bookmarked</A>
    <DT><A HREF="place:sort=14&type=6&maxResults=10&queryType=1">Recent Tags</A>
    <HR>
    <DT><A HREF="https://addons.mozilla.org/en-US/firefox/bookmarks/" ADD_DATE="1288945923" LAST_MODIFIED=

Restore All Bookmarks

We can restore our bookmarks from a previously created backup file, either one made automatically by Firefox or manually by a menu option. A restore process completely removes any existing traces of current bookmarks. In other words, it returns your bookmark file to the same way it was on a certain date.

To do this, click BOOKMARKS then SHOW ALL BOOKMARKS then click the STAR to open a menu of five options. The first two options are to BACK or RESTORE. Let your mouse cursor hover over the restore choice, or you may need to click it to see this panel :

Panel Showing Prior Bookmark Backup Files
Panel Showing Prior Bookmark Backup Files

Choose a date that your bookmarks were in a good state. Click the date with the entry matching that date. If all goes according to plan, all your existing bookmarks will be removed and in their place, a set of bookmarks for the start of day for your chosen date will now exist.

You might want to export your current bookmarks before you do this, so if anything goes arwy, you may be able to preserve some existing bookmarks.

End –

Hope that helps a little. 🙂