Richard Owlett wrote:
My bookmarks have grown like Topsy.
[ I've > 300 folders and >5000 bookmarks ]
I have many duplicates and the tree structure is a mess.
My goals include:
   1. Create a HTML file of bookmarks which:
      a. clearly shows the hierarchical structure of nested folders.
      b. allows searching for folder names as well as page titles.
      c. clearly shows in which the searched for file resides.
   2. find and purge duplicates.
   3. move folders around to create a more reasonable structure.

Looking for useful tools I found jq [https://stedolan.github.io/jq/].

An outline of my procedure is:
  1. export SeaMonkey bookmarks in JSON format.
  2. use jq to pretty print the JSON. {It does so nicely.}
  3. create HTML file described above.
  4. find duplicate targets and delete all but one.
  5. Each leaf of the bookmark tree is an object.
     Move these objects around to create a more friendly tree.
  6. Import the clean organized bookmarks.

The Tcl code below does #3. I've only sketched how to do #4.
[requires having done
     jq '.' yourrawbookmarks.json > prettytestalpha.json
]

Comments?



====================================================================

# Input is SeaMonkey bookmark file pretty printed with "jq"

set infile  "prettytestalpha.json"
set outfile "alphatest.html"

set fd_in  [open $infile  r]
set fd_out  [open $outfile w]

# set predefined values
set children    "\"child"
set uri        "\"uri\":"
set title        "\"title"
set rbracket    \]
set mylist [list $children $title $uri $rbracket]

# to be used at start of page of HTML
set preface {<html>
<head>
<title>PREalpha pretty bookmarks</title>
</head>
<body>
<h1>PREalpha pretty bookmarks</h1>
}
set postlude {</body>
</html>}


# a reminder of how to format a clickable link
# <a href="$url">$title</a>


set myline    0
set outline     0
set indent     ""
set plusindent     "&nbsp"
set sth1 "<h1>"
set enh1 "</h1>"
set aheading     0        ;# used to flag if $title is section label when =1

puts $fd_out $preface
while { ! [eof $fd_in] } {
       incr line
       gets $fd_in b_line
       set a_line [string trimleft $b_line]
       set c_line [string range $a_line 0 5]

       set x  [lsearch $mylist $c_line]
       if { ($x >= 0) } then {

         switch $x {
           0 {set indent $indent$plusindent; set aheading 1;}
           1 {set a_line [string replace $a_line 0 9];
              set a_line [string replace $a_line end-1 end];
              set title $a_line;
              if $aheading then {puts $fd_out "$sth1$indent$a_line$enh1";
              set aheading 0; incr myline}}
           2 {set a_line [string replace $a_line 0 6];
puts $fd_out "$indent&nbsp&nbsp<A HREF=$a_line>$title</A><br>";
incr outline }
           3 {set indent [string replace $indent end-4 end];}
           }
      }
}


puts $fd_out "<br><br>There are $myline folders<br>"
puts $fd_out "There are $outline bookmarks<br>"

puts $fd_out $postlude
close $fd_in
close $fd_out


Posting in this thread as it's gonna prove to be quite useful... and to help me locate it again when I have more time...

"A file that big?
  It might be very useful.
    But now it is gone."

from: http://www.thezensite.com/non_Zen/haiku_for_windows.html
_______________________________________________
support-seamonkey mailing list
support-seamonkey@lists.mozilla.org
https://lists.mozilla.org/listinfo/support-seamonkey

Reply via email to