Click here to Skip to main content
Click here to Skip to main content

Bookmark merger for Mozilla Firefox

By , 29 Nov 2006
 

Sample Image

Introduction

I could not find a simple tool to keep my Firefox bookmarks from work synchronized with my bookmarks at home, so I finally decided to write some code myself.

The code does not do (too) much, it solves the problem to some extend though: the program reads the "boookmarks.html" file from Firefox and treats it like a set of nodes.

Using the code

Just start the solution in VS2005 or another appropriate tool, the main engine can be found in the merge loop in MozillaLinkMerger.cs. Identify the file you want to use as the master file and some slave files you wish to merge into the master file. Don't worry, the original master file is saved in a different name (some GUID).

public void Merge()
{
    if (Stopped)
        return;

    //operation 1, read and parse master file
    string[] masterFileLines = 
       System.IO.File.ReadAllLines(_masterLinksFilePath);
    MozillaFile masterFile = new MozillaFile(masterFileLines);
    IncrementProgress();
    if (Stopped)
        return;

    //operation 2 - x, for each slave file read and parse links
    //run through each slave file
    foreach (string slaveFile in _slaveFiles)
    {
        string[] slaveFileLines = 
                 System.IO.File.ReadAllLines(slaveFile);
        MozillaFile slave = new MozillaFile(slaveFileLines);

        masterFile.Merge(slave);

        this.TotalNumberOfNewLinksFound = 
             masterFile.NumberOfNewLinksFound;

        IncrementProgress();
        if (Stopped)
            return;
    }
    if (RemoveDuplicates)
    {
        masterFile.RemoveDuplicateLinks();
    }

    //finally operation x + 1, print file to disk
    masterFile.Save(_mergedLinksFilepath);

    _isDone = true;
    IncrementProgress();
}

Points of Interest

Well, I did try to keep it simple.. If you are familiar with regular expressions, you may find better ways to identify links and folders in Firefox-bookmarks. I don't tend to write that many comments, so hopefully the code will be somewhat self-explaining.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Flandhart
Web Developer
Denmark Denmark
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralAnother tool...memberjuergy10 Dec '06 - 21:42 
is named Favsync and syncronizes your bookmarks through multiple machines and also syncs them with your IE Favorites. All you have to have is an ftp account on a machine on the web.
 
Cheers Juergen
GeneralGoogle alternativememberRokforus8 Dec '06 - 2:24 
GeneralNice, but...memberSoykaf4 Dec '06 - 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 29 Nov 2006
Article Copyright 2006 by Flandhart
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid