Joes has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone come across a Perl routine to sort bookmarks in Netscape Communicator 4.7 ?

It is a HTML file, with folders and bookmarks within folders, as well as bookmarks outside folders.

The idea is to sort the folders first, then the bookmarks within each folder, then the bookmarks outside the folders

Looking foreward to hearing from you, to save me re-inventing the wheel

Joe, Townsville

Replies are listed 'Best First'.
(atl: look on CPAN) Re: Sorting Netscape Browser Bookmarks
by atl (Pilgrim) on Jul 19, 2001 at 16:53 UTC

      Atl gives good advice, but I would actually go with URI-Bookmarks it is sorta the sequel to Netscape::Bookmarks.

      For starting code I would do something like this (as taken from the POD)...

      #!/usr/bin/perl use strict; use URI::Bookmarks; my $bookmarks = new URI::Bookmarks(file => "$ENVHOME}/.netscape/bookmarks.html"); my $bookmarks = new URI::Bookmarks(handle => $fh); my $bookmarks = new URI::Bookmarks(array => \@lines); # Manipulate $bookmarks using nice tree methods from Tree::DAG_Node, # e.g. delete all bookmarks under $folder: ($bookmarks->name_to_nodes($folder))[0]->unlink_from_mother(); # Then output the new file. print $bookmarks->export('Netscape array');


      HTH

      -foogod


      --- ruining the bell curve for everyone else ---
        Hi foogod,

        I didn't take the time to look into the modules, since the module names pretty much suggested that they were what this guy wants.

        However, Netscape::Bookmarks seemed fairly recent (last updated last may) which URI::Bookmarks seems less active (last updated november 1999). You're sure about that being a sequel?

        Have fun ...

        -atl

Re: Sorting Netscape Browser Bookmarks
by earthboundmisfit (Chaplain) on Jul 19, 2001 at 16:00 UTC
    I'm not aware of anything like that, but since Netscrape bookmarks are stored as an HTML file, you might look into HTML::Parser as the foundation on which you build your own custom solution.