###########################
#Bookmark Porter (beta) for BeOS, v0.1
#Converts Netscape bookmarks and Internet
#Explorer favorites to NetPositive format.
#
#Scot Hacker, 08/98, beos@birdhouse.org
#http://www.birdhouse.org/beos/software
###########################

Two quickie shell scripts to convert Netscape Navigator and Internet Explorer favorites into NetPositive's bookmark format. There are, however, a number of caveats -- see the bug notes below.

Usage

After choosing an installation directory, open up the two scripts and edit the first lines so that they match the actual paths of your Input and Output bins. After editing these paths and saving, drag bookmarkporter.ie and bookmarkporter.ns into /boot/home/config/bin.

Converting Netscape bookmarks

Cart your Netscape bookmarks file (usually bookmark.htm or bookmark.html) over to your BeOS partition by whatever means necessary and drop it into this directory (or wherever you like). Make sure the path to the Output directory listed at the top of the script is accurate, open a Terminal, and type

bookmarkporter.ns /boot/home/bookmarks.html

or whatever. You can use any path or filename you like. 

Replicating the text-based bookmark folder hierarchy as a real directory tree proved to be trickier than expected. This script is slow and buggy, but it will convert probably 90-95% of your bookmarks properly. Speed depends on the number of bookmarks and the number of subdirectories to be plowed through. If you have a ton of bookmarks, the script may appear to freeze at points; give it a chance. It takes about 10 minutes to do 500 bookmarks on my machine.

The Output directory will fill up with bookmarks and folders. When done, you can drag them into NetPositive's bookmarks (the script will offer to launch the appropriate folders for you when finished).

Converting IE Fravrites

IE's "one file per favorite" format is already similar to NetPositive's, so this script is a little faster and less buggy than the Netscape converter. From within Windows, zip up your c:\windows\favorites directory, remembering to tell your zipper to respect the directory tree (from the command line, use the -r flag; WinZip makes this easy). You don't even to have to zip them if you don't want to. If you're on a dual-boot machine, you can just copy the directory over to a BeOS partition. FTP, sneakernet, whatever. Plop the whole thing into the Input folder, make sure the path at the top of the script is accurate, open a Terminal, and type: boomarkporter.ie .

I know it doesn't make any sense, but IE favorites stay in the Input folder when cooked -- don't look for them in Output bin because they won't show up there. It was just easier this way...

About Attributes and NetPositive 2

NetPositive uses Tracker in an unusual way, by making an Attribute column ("Title") the primary viewing mode. Actual filenames for Net+ bookmarks are Unix-style creation-date codes (number of seconds elapsed since New Year's eve, 1970). The reason for this is that these names are almost guaranteed to be unique, and you'll never have overwrite problems with them. The downside is that you have to hand-tweak every single subdirectory to make the Title attribute visible in Tracker. Personally, I don't have a problem with bookmarks being overwritten, and I really hate the fact that you get nothing but a string of digits when you drag a NetPositive bookmark to the desktop. 

The Netscape script here defaults to naming bookmark files with the site's title, rather than the bookmark's creation date. If you want to change that, replace every instance of "$title" with "$time" in bookmarkporter.ns.

The IE script also writes bookmark files as titles rather than times -- the IE format would have made it way too hard to do anything but. You'll find the site title residing in both the filename and the Title attribute with these scripts.


About the Index

In order for new bookmarks to be queryable under this new system, BeOS needs to maintain an index of the META:title attribute. However, 3.2 does not do this, so newly created bookmarks aren't searchable by Title right now. This doesn't affect bookmarks created by these scripts since they save the Title to both filename and attribute, but  both scripts check to see whether your system is indexing META:title, and offers to turn it on for you if not. Just a convenience.


Limitations and Bugs

These scripts won't eat your hard drive or anything, but they are definitely buggy. I'm releasing them because I don't have time to work on them and they're solid enough to be useful. The Netscape script is worse than the IE one, and is almost guaranteed to miss a few of your bookmarks or get them in the wrong folder. Both scripts will keep running to completion even if they stumble a bit. Specifically, it will semi-choke on any bookmark that has a slash in its name (like OS/2 sites), and it doesn't like ftp:// or gopher:// addresses too much either.

Because I don't know jack about crawling directory trees, the Netscape script is hard-wired to a depth limit of five nested folders. I haven't tested with more than that -- no guarantees. Nor have I tested bookmark files from MacOS or Linux yet. If you do, please let me know how it went.

On a few sample Netscape files, I've ended up with non-printing characters at the ends of some filenames. If this happens to you, download BeStripper from BeWare, run your bookmark.html file through it, and re-run the script. Remember to empty the Output or Input directories before re-running them or you'll get error messages.

Finally, I've had a few folders in the generated bookmark trees mistakenly set with a bookmark MIME type, and I can't figure out what's causing it. These folders look normal, but won't open when double-clicked. The fix is to open up the folder's FileType dialog and set the MIME string to application/x-vnd.Be-directory. Also make sure that Tracker is the preferred app for the folder, not NetPositive.


        The BeOS Tip Server
http://www.birdhouse.org/beos/tips

