Using jq to clean/organize bookmarks?

My bookmarks have grown like Topsy
I have many duplicates and the tree structure is a mess.
I have two primary goals:
   1. find and purge duplicates.
   2. move folders around to create a more reasonable structure.

After trying several approaches and looking for useful tools I found
jq [https://stedolan.github.io/jq/]. One related page I found is titled 
"jq is sed for JSON".

An outline of a possible procedure might be:
  1. Export SeaMonkey bookmarks in JSON format.
  2. use jq to pretty print the JSON. It does so nicely.
  3. Find duplicate targets and delete all but one.
  4. Each leaf of the bookmark tree is an object.
     Move these objects around to create a more friendly tree.
  5. Import the clean organized bookmarks.

Has anyone done this?
Is there a friendly in depth jq tutorial? The ones I've found tend to be 
on the "Hello world" level. There is just enough to tantalize.

Links of interest include:
https://stedolan.github.io/jq/manual/v1.5/
http://stedolan.github.io/jq/tutorial/
https://robots.thoughtbot.com/jq-is-sed-for-json





0
Richard
8/8/2018 12:38:04 PM
mozilla.support.seamonkey 12906 articles. 0 followers. Post Follow

4 Replies
13 Views

Similar Articles

[PageSpeed] 20

Richard Owlett wrote on 8/08/2018 10:38 PM:
> My bookmarks have grown like Topsy I have many duplicates and the
> tree structure is a mess. I have two primary goals: 1. find and purge
> duplicates. 2. move folders around to create a more reasonable
> structure.
> 
> After trying several approaches and looking for useful tools I found 
> jq [https://stedolan.github.io/jq/]. One related page I found is
> titled "jq is sed for JSON".
> 
> An outline of a possible procedure might be:
> 1. Export SeaMonkey bookmarks in JSON format.
> 2. use jq to pretty print the JSON. It does so nicely.
> 3. Find duplicate targets and delete all but one.
> 4. Each leaf of the bookmark tree is an object. Move these objects >around to create a more friendly tree.
> 5. Import the clean organized bookmarks.
> 
> Has anyone done this? Is there a friendly in depth jq tutorial? The
> ones I've found tend to be on the "Hello world" level. There is just
> enough to tantalize.
> 
> Links of interest include: 
> https://stedolan.github.io/jq/manual/v1.5/ 
> http://stedolan.github.io/jq/tutorial/ 
> https://robots.thoughtbot.com/jq-is-sed-for-json
> 
Richard, you have my attention! About a month ago, I asked, here, about 
sorting out duplicate, or even triplicate, entries in the Bookmarks folder.

I've got zero experience with JSON, but will be interested in any 
discussion here!

-- 
Daniel

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
SeaMonkey/2.49.1 Build identifier: 20171016030418

User agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
SeaMonkey/2.49.1 Build identifier: 20171015235623
0
Daniel
8/8/2018 1:34:26 PM
On 08/08/2018 08:34 AM, Daniel wrote:
> Richard Owlett wrote on 8/08/2018 10:38 PM:
>> My bookmarks have grown like Topsy I have many duplicates and the
>> tree structure is a mess. I have two primary goals: 1. find and purge
>> duplicates. 2. move folders around to create a more reasonable
>> structure.
>>
>> After trying several approaches and looking for useful tools I found 
>> jq [https://stedolan.github.io/jq/]. One related page I found is
>> titled "jq is sed for JSON".
>>
>> An outline of a possible procedure might be:
>> 1. Export SeaMonkey bookmarks in JSON format.
>> 2. use jq to pretty print the JSON. It does so nicely.
>> 3. Find duplicate targets and delete all but one.
>> 4. Each leaf of the bookmark tree is an object. Move these objects 
>> >around to create a more friendly tree.
>> 5. Import the clean organized bookmarks.
>>
>> Has anyone done this? Is there a friendly in depth jq tutorial? The
>> ones I've found tend to be on the "Hello world" level. There is just
>> enough to tantalize.
>>
>> Links of interest include: https://stedolan.github.io/jq/manual/v1.5/ 
>> http://stedolan.github.io/jq/tutorial/ 
>> https://robots.thoughtbot.com/jq-is-sed-for-json
>>
> Richard, you have my attention! About a month ago, I asked, here, about 
> sorting out duplicate, or even triplicate, entries in the Bookmarks folder.
> 
> I've got zero experience with JSON, but will be interested in any 
> discussion here!
> 

If you know the bookmark's title or uri you can do it manually.
Use the bookmarks manager to export in JSON format.
Make a copy in another directory to manipulate.
Run jq's pretty print function to create a file to edit.
Open with a plain text editor (notebook etc).

Search for your duplicated book mark.

A sample from my system is:

> 
>                 {
>                   "guid": "yb3hKkKKqQSh",
>                   "title": "Debootstrap (Shallow Thoughts)",
>                   "index": 1,
>                   "dateAdded": 1487768687157000,
>                   "lastModified": 1487768687157000,
>                   "id": 34488,
>                   "iconuri": "http://shallowsky.com/favicon.ico",
>                   "type": "text/x-moz-place",
>                   "uri": "http://shallowsky.com/blog/linux/install/debootstrap.html"
>                 },
> .
> .
> .
> 
>                         {
>                           "guid": "hvuonjDqIu5X",
>                           "title": "Debootstrap (Shallow Thoughts)",
>                           "index": 2,
>                           "dateAdded": 1488384546925000,
>                           "lastModified": 1488384546925000,
>                           "id": 34549,
>                           "iconuri": "http://shallowsky.com/favicon.ico",
>                           "type": "text/x-moz-place",
>                           "uri": "http://shallowsky.com/blog/linux/install/debootstrap.html"
>                         },
> 


Note the different indentations. That is an indicator of how deeply 
nested that occurrence is.

Delete everything "{" to "}" inclusive. If there is a comma after the 
closing brace, delete it also.

Repeat for other duplicates.

Use the bookmark manager's restore function to load the edited JSON.
There should be no problem. You did start with a backup didn't you?
<grin>

I'm looking to automate it as I have no idea which have duplicates.
HTH


0
Richard
8/8/2018 2:41:43 PM
On 08/08/2018 09:41 AM, Richard Owlett wrote:
> On 08/08/2018 08:34 AM, Daniel wrote:
>> Richard Owlett wrote on 8/08/2018 10:38 PM:
>>> My bookmarks have grown like Topsy I have many duplicates and the
>>> tree structure is a mess. I have two primary goals: 1. find and purge=

>>> duplicates. 2. move folders around to create a more reasonable
>>> structure.
>>>
>>> After trying several approaches and looking for useful tools I found =

>>> jq [https://stedolan.github.io/jq/]. One related page I found is
>>> titled "jq is sed for JSON".
>>>
>>> An outline of a possible procedure might be:
>>> 1. Export SeaMonkey bookmarks in JSON format.
>>> 2. use jq to pretty print the JSON. It does so nicely.
>>> 3. Find duplicate targets and delete all but one.
>>> 4. Each leaf of the bookmark tree is an object. Move these objects=20
>>> >around to create a more friendly tree.
>>> 5. Import the clean organized bookmarks.
>>>
>>> Has anyone done this? Is there a friendly in depth jq tutorial? The
>>> ones I've found tend to be on the "Hello world" level. There is just
>>> enough to tantalize.
>>>
>>> Links of interest include: https://stedolan.github.io/jq/manual/v1.5/=
=20
>>> http://stedolan.github.io/jq/tutorial/=20
>>> https://robots.thoughtbot.com/jq-is-sed-for-json
>>>
>> Richard, you have my attention! About a month ago, I asked, here,=20
>> about sorting out duplicate, or even triplicate, entries in the=20
>> Bookmarks folder.
>>
>> I've got zero experience with JSON, but will be interested in any=20
>> discussion here!
>>
>=20
> If you know the bookmark's title or uri you can do it manually.
> Use the bookmarks manager to export in JSON format.
> Make a copy in another directory to manipulate.
> Run jq's pretty print function to create a file to edit.
> Open with a plain text editor (notebook etc).
>=20
> Search for your duplicated book mark.
>=20
> A sample from my system is:
>=20
>>
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "guid": "yb3hKkKKqQSh",
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "title": "Debootstrap (Shallow Thoughts)",=

>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "index": 1,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "dateAdded": 1487768687157000,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "lastModified": 1487768687157000,
>> =C2=A0=C2=A0=C2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C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 "type": "text/x-moz-place",
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 "uri":=20
>> "http://shallowsky.com/blog/linux/install/debootstrap.html"
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 },
>>
>=20
>=20
> Note the different indentations. That is an indicator of how deeply=20
> nested that occurrence is.
>=20
> Delete everything "{" to "}" inclusive. If there is a comma after the=20
> closing brace, delete it also.
>=20
> Repeat for other duplicates.
>=20
> Use the bookmark manager's restore function to load the edited JSON.
> There should be no problem. You did start with a backup didn't you?
> <grin>
>=20
> I'm looking to automate it as I have no idea which have duplicates.
> HTH
>=20
>=20

I've blocked out a method to list all unique titles and purge=20
duplicates. Hopefully I'll have something workable early next weeks.



0
Richard
8/8/2018 6:09:24 PM
Richard Owlett wrote on 9/08/2018 4:09 AM:
> On 08/08/2018 09:41 AM, Richard Owlett wrote:
>> On 08/08/2018 08:34 AM, Daniel wrote:
>>> Richard Owlett wrote on 8/08/2018 10:38 PM:
>>>> My bookmarks have grown like Topsy I have many duplicates and
>>>> the tree structure is a mess. I have two primary goals: 1. find
>>>> and purge duplicates. 2. move folders around to create a more
>>>> reasonable structure.
>>>> 
>>>> After trying several approaches and looking for useful tools I
>>>> found jq [https://stedolan.github.io/jq/]. One related page I
>>>> found is titled "jq is sed for JSON".
>>>> 
>>>> An outline of a possible procedure might be: 1. Export
>>>> SeaMonkey bookmarks in JSON format. 2. use jq to pretty print
>>>> the JSON. It does so nicely. 3. Find duplicate targets and
>>>> delete all but one. 4. Each leaf of the bookmark tree is an
>>>> object. Move these objects
>>>>> around to create a more friendly tree.
>>>> 5. Import the clean organized bookmarks.
>>>> 
>>>> Has anyone done this? Is there a friendly in depth jq tutorial?
>>>> The ones I've found tend to be on the "Hello world" level.
>>>> There is just enough to tantalize.
>>>> 
>>>> Links of interest include: 
>>>> https://stedolan.github.io/jq/manual/v1.5/ 
>>>> http://stedolan.github.io/jq/tutorial/ 
>>>> https://robots.thoughtbot.com/jq-is-sed-for-json
>>>> 
>>> Richard, you have my attention! About a month ago, I asked, here,
>>>  about sorting out duplicate, or even triplicate, entries in the
>>>  Bookmarks folder.
>>> 
>>> I've got zero experience with JSON, but will be interested in any
>>>  discussion here!
>>> 
>> If you know the bookmark's title or uri you can do it manually. Use
>> the bookmarks manager to export in JSON format. Make a copy in
>> another directory to manipulate. Run jq's pretty print function to
>> create a file to edit. Open with a plain text editor (notebook
>> etc).
>> 
>> Search for your duplicated book mark.
>> 
>> A sample from my system is:
>>> 
>>> { "guid": "yb3hKkKKqQSh", "title": "Debootstrap (Shallow
>>> Thoughts)", "index": 1, "dateAdded": 1487768687157000, 
>>> "lastModified": 1487768687157000, "id": 34488, "iconuri":
>>> "http://shallowsky.com/favicon.ico", "type": "text/x-moz-place", 
>>> "uri": 
>>> "http://shallowsky.com/blog/linux/install/debootstrap.html" }, . 
>>> . .
>>> 
>>> { "guid": "hvuonjDqIu5X", "title": "Debootstrap (Shallow
>>> Thoughts)", "index": 2, "dateAdded": 1488384546925000, 
>>> "lastModified": 1488384546925000, "id": 34549, "iconuri": 
>>> "http://shallowsky.com/favicon.ico", "type": "text/x-moz-place", 
>>> "uri": 
>>> "http://shallowsky.com/blog/linux/install/debootstrap.html" },
>> 
>> Note the different indentations. That is an indicator of how deeply
>>  nested that occurrence is.
>> 
>> Delete everything "{" to "}" inclusive. If there is a comma after
>> the closing brace, delete it also.
>> 
>> Repeat for other duplicates.
>> 
>> Use the bookmark manager's restore function to load the edited
>> JSON. There should be no problem. You did start with a backup
>> didn't you? <grin>
>> 
>> I'm looking to automate it as I have no idea which have
>> duplicates. HTH
> 
> I've blocked out a method to list all unique titles and purge 
> duplicates. Hopefully I'll have something workable early next weeks.
> 
Hey, I've been waiting a couple of months, Richard, a couple of weeks 
more should be no problem. Best of luck with your endeavours!

-- 
Daniel

User agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
SeaMonkey/2.49.1 Build identifier: 20171016030418

User agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
SeaMonkey/2.49.1 Build identifier: 20171015235623
0
Daniel
8/9/2018 7:49:18 AM
Reply: