Last active
September 28, 2018 11:24
-
-
Save dwallraff/2f7aa41d0424bf06d4c0d83642e84d0f to your computer and use it in GitHub Desktop.
Export all non-trashed docs from 1Password
This file contains hidden or 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
#! /usr/bin/env bash | |
## Copy all docs from 1password | |
mkdir files || exit | |
# Get all current (non-trashed) doc UUIDs and titles | |
# shellcheck disable=2016 | |
op list documents | jq -r '. as $in | keys[] | select($in[.].trashed=="N") as $res | [$in[$res].uuid, $in[$res].overview.title] | @json' > files/docs_list | |
# Loop over list and save each one off | |
TOTAL="$(wc -l < files/docs_list)" | |
for ((i=1; i<="$TOTAL"; i++)) | |
do | |
FILENAME="" | |
UUID="" | |
let COUNT=$i-1 | |
UUID=$(jq -rs '.['"$COUNT"'][0]' < files/docs_list) | |
FILENAME=$(op get item "$UUID" | jq -r '.details.documentAttributes.fileName') | |
if [ -z "$FILENAME" ]; then | |
FILENAME=$(jq -rs '.['"$COUNT"'][1]' < docs_list) | |
fi | |
echo "Getting doc $i of $TOTAL: $FILENAME ($UUID)..." | |
op get document "$UUID" > files/"$FILENAME" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment