I’ve been recently thinking about migrating from LastPass to BitWarden due to the recent incident and how they are dealing with.
The problem is that I had already created a BitWarden account and imported some of my passwords in 2020. So, when I imported all of my passwords (old and new) again I created lots of duplicates.
Luckily BitWarden offers a CLI and after playing with it a bit a find a way to move all the “old” passwords created in 2020 in another folder, which will be then deleted by me manually. I could went ahead and deleted all of those passwords but I just wanted to be sure that I’m not deleting something that it’s not in the LastPass account.
The bash script is:
bw list items --folderid "<SOURCE_FOLDER_ID or null>" | jq -c '.[] | select (.creationDate | startswith("2020")) | .folderId = "<DESTINATION_FOLDER_ID>"' | while read obj; do echo `bw edit item $(jq -r .id <<< "$obj") $(bw encode <<< "$obj")`; done;
It basically ask for the list of items in a specific folder (null
in my case) taking only those created in 2020 and attaches the destination folder id by using jq and then cycle trough them and update via the BW cli once again one a the time.
It’s not really fast since each of the item must be encoded and updated. In my case for ~90 items it took ~4 minutes.