-
-
Save voice1/58159602be2d9ef6cdb72b8c2224ca72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BitWarden tool to delete folders using bw CLI tool | |
# 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. | |
# NOTE: I use the utility sh (https://github.com/amoffat/sh) rather then os or subprocess, as I find it easier | |
import sh | |
import json | |
session_key = "Replace me with your session key" | |
# Sets this instance to use the provided session. | |
bw = sh.bw.bake('--session', session_key) | |
folders = bw('list', 'folders') | |
# The output provided is a string, luckily we can convert this to JSON | |
folders = json.loads(folders.stdout) | |
# Delete all the folders.. Add logic here if you want only a subset. | |
for folder in folders: | |
if folder.get('id'): | |
print(f"removing folder {folder['id']} {folder['name']}") | |
bw("delete", "folder", folder['id']) |
Forked and make a Delete All Collections version: https://gist.github.com/eduncan911/c0f4d789b87c3746a055779a57ff57e5
if you down lod the cli on the mainpage it is currently blocked by issue bitwarden/clients#4040 on Version 2022.11.0
but works on https://github.com/bitwarden/cli/releases // Version 1.22.1
dosent work on windows see https://gist.github.com/KingWaffleIII/f346d737cc9445d938612c93daca7dd5 using subprocess
I had forgotten about this and honestly wasn't paying attention. Glad it's useful to others.
Thank you for the script! Is there an extra indent on line 24? Everything else worked great.
@timskkim You are correct, I updated it. Believe it was a formatting issue due to copy and pasting of a gist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the script! Is there an extra indent on line 24? Everything else worked great.