#!/usr/bin/python # Copyright (c) 2004 Randy Gamage # Written 9/19/03 # Script to export Opera Bookmarks to HTML, for easy posting on the web # I realize this code is ugly and inefficient- please send me ideas for improvement! from string import * # Set this to your source/destination file path bookmarkpath = "D:\\Data\\Profiles\\rgamage\\Application Data\\Opera\\Opera7\\profile\\" # Set this to your source file name bookmarkname = 'opera6.adr' # Set this to your desired output file name. Warning - this will overwrite with no warnings! outfilename = 'mylinks.html' fname = bookmarkpath + bookmarkname foldermode = 0 foldername = 'Un-Categorized' URLname = '' URL = '' f = open(fname,'rb') bmlist = f.readlines() #List with n elements, each a line f.close() linkdict = {} otherdict = {} fname = bookmarkpath + outfilename f = open(fname,'w') for i in bmlist: try: if foldermode and i.find('NAME=')==1: foldername = i[6:-2] f.write("

" + foldername + "

\n") if not foldermode and i.find('NAME=')==1: URLname = i[6:-2] if not foldermode and i.find('URL=')>-1: URL = i[5:-2] if foldername == 'Un-Categorized': # This link is not in any folder, so save for later otherdict[URL] = URLname else: # This link is in a known folder, so list it now linkdict[URL] = URLname f.write(" " + URLname + "
\n") if i.find('#FOLDER')==0: foldermode=1 if i.find('#URL')==0: foldermode=0 if i.find('-')==0: foldermode=0 foldername = 'Un-Categorized' except: print 'Some sort of Error occurred' f.write("

Un-Categorized

\n") for URL,URLname in otherdict.items(): f.write(" " + URLname + "
\n") f.close() print "OK we're totally done.\n"