This Script Copies Description, Separators, etc. from HTML to Existing Vivaldi Bookmarks
-
Re: Import/Export ALL Supported Bookmark Properties
Script
annotate_vivaldi_bookmarks.pl
copies bookmark Descriptions, Nicknames, Tags, and Separators from a Firefox bookmarks HTML file to existing Vivaldi bookmarks. It does not import bookmarks and their properties, but you can do that in two steps.I wrote the script to solve the following problem, and polished it up in hopes it will be useful to others.
In 2019, before Firefox abandoned support for Bookmark Descriptions, I saved mine by exporting a Firefox HTML Bookmarks file. Subsequently in Firefox I added, deleted, and reorganized various bookmarks. Eventually I imported the new bookmarks tree into Vivaldi (losing Separators), and made further additions and changes (including Descriptions and Nicknames). Now I wanted to restore the Descriptions etc. from the old HTML file into my current Vivaldi bookmarks, wherever they may be in the current bookmarks tree.
That is what this script does. It matches bookmarks from the HTML to bookmarks in Vivaldi by Date Added, URL, Name, and a portion of the folder path, and copies the properties to that match.
Here is an example run (on Windows 10). Thirty warnings and notes may seem like a lot, but it's only 2% compared to the number of changes made.
set BOOKMARKS="%LOCALAPPDATA%\Vivaldi\User Data\Default\Bookmarks" set HTML="C:\Data\WWW\Checkpoints\GJS Bookmarks 2019-07-18 1732.html" perl -S annotate_vivaldi_bookmarks.pl -trees %HTML% %BOOKMARKS% annotate_vivaldi_bookmarks.pl - Checking Vivaldi Profile Lock ... annotate_vivaldi_bookmarks.pl - Backing up Vivaldi Bookmarks (JSON file) ... annotate_vivaldi_bookmarks.pl - NOTE: 'Default/Bookmarks' backup copy is still current. annotate_vivaldi_bookmarks.pl (./Default/Checkpoints/Bookmarks 2021-02-25 1755). annotate_vivaldi_bookmarks.pl - Reading JSON Bookmarks ... annotate_vivaldi_bookmarks.pl - Processing HTML Bookmarks ... annotate_vivaldi_bookmarks.pl - WARNING: Folder not found: New Bookmarks annotate_vivaldi_bookmarks.pl - WARNING: Bookmark not found: TT18D: Formosa Oolong Choicest - 160g (... 25 more messages ...) annotate_vivaldi_bookmarks.pl - WARNING: Folder not unique: Forums annotate_vivaldi_bookmarks.pl - NOTE: Bookmark has moved: Using the viewport meta tag to control ... annotate_vivaldi_bookmarks.pl - WARNING: Bookmark not found: d some annotate_vivaldi_bookmarks.pl - Writing JSON Bookmarks ... annotate_vivaldi_bookmarks.pl - Copying JSON Bookmarks to Vivaldi Profile ... annotate_vivaldi_bookmarks.pl - Checked 12,372 bookmarks and 2,571 folders in 13 seconds. annotate_vivaldi_bookmarks.pl - Updated 790 Descriptions, 6 Shortcuts, and 0 Tags. annotate_vivaldi_bookmarks.pl - Checked 1,037 Separators, added 997. 23 were already present. annotate_vivaldi_bookmarks.pl - Logged 16 WARNINGs and 14 NOTEs. annotate_vivaldi_bookmarks.pl - For details see 'annotate_vivaldi_bookmarks.log'.
The log file details the changes made and not made. It is intended as a preview before doing the update, and as an aid to making any needed corrections in Vivaldi afterward. Here is a sample entry:
NOTE: Bookmark has moved: Coffee Terms - Cupping and Tasting UPDATED Bookmark: x Bookmarks > Other Bookmarks > Coffee Terms - Cupping and Tasting > Bookmarks > Home > Food / Cooking > Coffee > Coffee Terms - Cupping and Tasting http://www.zecuppa.com/coffeeterms-cupping-tasting.htm Date Added: 06 Sep 2018, 9:47:17 AM > Description: Coffee Terms > Cupping, Tasting > Coffee term descriptions and illustrations
If you want to import an HTML Bookmarks file complete with Descriptions etc. into Vivaldi, you can:
- Import the HTML Bookmarks file into Vivaldi as usual to create the Folders, Bookmarks, URLs, and Favicons. Note the folder where Vivaldi placed the bookmarks, e.g. Imported (1).
- Run the script to finish the job, specifying the folder where the Descriptions etc. should be copied. For example:
> annotate_vivaldi_bookmarks -root "Imported (1)" ...
[Currently this script does not copy Bookmark Thumbnails. However, I could add an option without much trouble if anyone needs to import them.]
To run the script you need a Perl interpreter and libraries. I have tested the script on Windows 10 Home 20H2 with ActivePerl 5.24 and Strawberry Perl 5.32, both of which include everything needed. ActivePerl is also available for Linux and Mac.
Details at Annotate Vivaldi Bookmarks. You can download the script from annotate_vivaldi_bookmarks.zip.
Please let me know of any problems with the script.
-
This is great, well done
I don't use a lot of annotations for my ~800 bookmarks, I probably should, but I rely on a good folder structure to find what I need instead. I guess with 12k bookmarks it would not be enough to just rely on folders
Had a look at the code and documentation, looks really impressive! It would be fun to test it out, I would need to use a backup profile I guess as I'm not brave enough to run it directly on my main profile.
-
@Pathduck -- Thanks for the compliment.
I too had to build up some courage before running the script on my main profile. I only did it after many runs in development/test profiles, and later in
-preview
mode (which creates the log file but does not update the Vivaldi profile). If you are interested, and have an old HTML file with Descriptions or Separators for your current bookmarks, you could try running the script with-preview
to see what it would do. -
@Gwen-Dragon -- Could you please add tags Bookmarks and Import to this topic, in case anyone is still using tags for search?
-
@gjs Greetings. I am new to Vivaldi (as of today). I successfully imported my Firefox bookmarks from an html export. Now, I wish to bring in my keywords as nicknames and my separators, but not tags. I successfully installed activeperl, per your suggestion. But I have no idea how to proceed next; the usage instructions are a bit Greekish to me. Do I need to contionue working inside a CMD window? do I need to launch perl (how?)?
I see these 3 lines at the beginning of the Windows example:
set BOOKMARKS="%LOCALAPPDATA%\Vivaldi\User Data\Default\Bookmarks"
set HTML="C:\Data\WWW\Checkpoints\GJS Bookmarks 2019-07-18 1732.html"
perl -S annotate_vivaldi_bookmarks.pl -trees %HTML% %BOOKMARKS%But when I type the first line into the CMD window, I get back a message saying that "BOOKMARKS" is not a valid command. This, of course, makes sense, but I've never done this before and don't know how to proceed next.
I would be grateful for help moving forward. Thank you!
-
@vlmin said in This Script Copies Description, Separators, etc. from HTML to Existing Vivaldi Bookmarks:
set BOOKMARKS="%LOCALAPPDATA%\Vivaldi\User Data\Default\Bookmarks"
Are you leaving out the
set
command?It should look like this:
Last two commands are for verifying that the variables have been set.
-
I think I'm using them correctly.
echo %bookmarks% shows the correct path to the Vivaldi bookmarks.
echo %html% shows: "C:!!_My\Pale Moon_FEBE CLEO OPIE\FEBE 2021 08-03 23.00.01\bookmarks{default}.html" , which is indeed the location of the file I wish to use.
Since my last message, I did figure out how to run the script … I think. It now says there is an error at line 69. The whole thing displays as follows:
[ActiveState/Perl-5.32] Q:\IT & Phone_First Apps\Part 2\Vivaldi — Annotate Bookmarks script>perl -S annotate_vivaldi_bookmarks.pl -trees %HTML% %BOOKMARKS%
Can't locate HTML/Entities.pm in @INC (you may need to install the HTML::Entities module) (@INC contains: C:/bin . C:/Users/VLMin 001/AppData/Local/activestate/ec2e3729/site/lib C:/Users/VLMin 001/AppData/Local/activestate/ec2e3729/lib) at annotate_vivaldi_bookmarks.pl line 69.
BEGIN failed--compilation aborted at annotate_vivaldi_bookmarks.pl line 69.So I've moved forward a bit but am now stuck in a new place. I have no idea what the HTML::Entities module may be, or whether I need to install it. I hope this is my error and not one in the script, because then, barring a response from the author, I'm stopped altogether.
Thank you!!!
-
@vlmin said in This Script Copies Description, Separators, etc. from HTML to Existing Vivaldi Bookmarks:
echo %html% shows: "C:!!_My\Pale Moon
What are those
!!
doing there? Surely it's supposed to be\\
?Are you manually typing out these commands? You know you can copy and paste text in CMD right?
The error says you might need to install the Perl module called HTML::Entities. I don't use ActivePerl so I don't know the details of how to do that. Try searching for the module on their site:
https://code.activestate.com/ppm/ -
@GJS
Thank you! Even after I mess with the bookmarks (no renaming though) and tree (order and renaming), it work almost flawlessly. The log is nice. Days of work saved. -
@VLMin -- I apologize for the late response. I have been preoccupied with other things, and not checking this forum regularly. For some reason I did not receive an Email notification of your replies, even though I have "Watching" set.
HTML::Entities is a standard Perl module, and should be located in the lib/HTML folder under your Perl installation. My installations of ActivePerl and StrawberryPerl installed it at the following paths, respectively:
C:\Programs\Perl\lib\HTML\Entities.pm C:\Programs\StrawberryPerl\perl\vendor\lib\HTML\Entities.pm
From the messages:
[ActiveState/Perl-5.32] Q:\IT & Phone_First Apps\Part 2\Vivaldi — Annotate Bookmarks script>perl -S annotate_vivaldi_bookmarks.pl -trees %HTML% %BOOKMARKS% Can't locate HTML/Entities.pm in @INC (you may need to install the HTML::Entities module) (@INC contains: C:/bin . C:/Users/VLMin 001/AppData/Local/activestate/ec2e3729/site/lib C:/Users/VLMin 001/AppData/Local/activestate/ec2e3729/lib ) at annotate_vivaldi_bookmarks.pl line 69.
it looks like you have Perl 5.32 installed for single user. If that is the case, then running:
cd "C:\Users\VLMin 001\AppData\Local\activestate\ec2e3729\" dir /s /b Entities.pm
should show the full path of HTML/Entities.pm.
If you get 'File not found' then there may be a problem with the Perl installation. I am using Perl 5.24 installed for all users, so to duplicate the problem I would have to replicate your Perl installation.
Please let me know if you still need help. And again, sorry for the delay.