Skip to content

Instantly share code, notes, and snippets.

@rskuipers
Created March 4, 2020 21:34
Show Gist options
  • Save rskuipers/f5bab4f707f7052283aa3cee604e130b to your computer and use it in GitHub Desktop.
Save rskuipers/f5bab4f707f7052283aa3cee604e130b to your computer and use it in GitHub Desktop.
Move all items in bitwarden vault that don't belong to an organization to your personal folder
#!/bin/bash
# Download and install bitwarden CLI: https://help.bitwarden.com/article/cli/
# First login to access your vault:
# $ bw login
# Export the session variable as explained in the login output:
# export BW_SESSION="..."
# Get personal folder ID with:
# $ bw list folders
# Change personal folder id below
personal_folder_id="c2feb789-f2e4-40b4-be39-ab7401484d10"
for row in $(bw list items --organizationid null | jq -r '.[] | @base64'); do
row=$(echo "$row" | base64 -d -)
name=$(echo "$row" | jq -r '.name')
folder_id=$(echo "$row" | jq -r '.folderId')
if [ "$folder_id" != "null" ]; then
echo "Skipping $name"
continue
fi
row_id=$(echo "$row" | jq -r '.id')
echo "$row" | jq ".folderId = \"$personal_folder_id\"" | base64 -w0 | bw edit --quiet item "$row_id"
echo "Updated $name"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment