新文件: script/bitwarden-remove-folders.py 新文件: script/folders 修改: script/jbl.sh Signed-off-by: H <huone2019@outlook.com>
34 lines
1.2 KiB
Python
Executable File
34 lines
1.2 KiB
Python
Executable File
# BitWarden tool to delete collections using bw CLI tool
|
|
# forked from: https://gist.github.com/voice1/58159602be2d9ef6cdb72b8c2224ca72
|
|
|
|
# requirements: need to install "sh" python module:
|
|
#
|
|
# $ pip3 install sh
|
|
#
|
|
|
|
# You must install the bitwarden CLI tool (https://bitwarden.com/help/article/cli/#download-and-install)
|
|
# Create your session as per the instructions on the download page.
|
|
# You can replace your session key and use the following to process the results.
|
|
|
|
import sh
|
|
import json
|
|
|
|
#session_key = "<REPLACE-WITH-YOUR-CLI-SESSION-KEY>"
|
|
session_key = "IcBa9jFuHUv46Psk2nowv7Le3v7h1l0e+I0SuNDVovNtPbLrsUCuRQ7eJKr0G6nWR3piWM4vAT735kWByAlrgA=="
|
|
|
|
# Sets this instance to use the provided session.
|
|
bw = sh.bw.bake('--session', session_key)
|
|
|
|
collections = bw('list', 'collections')
|
|
|
|
# The output provided is a string, luckily we can convert this to JSON
|
|
collections = json.loads(collections.stdout)
|
|
|
|
# Delete all the collections.. Add logic here if you want only a subset.
|
|
for collection in collections:
|
|
if collection.get('id'):
|
|
printf("removing collection {collection['id']} {collection['name']} {collection['organizationId']}")
|
|
bw("delete", "org-collection", collection['id'], "--organizationid", collection["organizationId"])
|
|
|
|
print('done')
|