Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active November 28, 2017 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/45161d86b4d5bde45ad473db57d07b81 to your computer and use it in GitHub Desktop.
Save kou1okada/45161d86b4d5bde45ad473db57d07b81 to your computer and use it in GitHub Desktop.
KeePass export XML utilities

KeePass export XML utilities

License

MIT license.

Requirements

Usage

To export hoge.xml from hoge.kdbx as below:

keepass-exportxml hoge.kdbx

To check deleted UUID as below:

keepass-checkdeleted hoge.xml
#!/usr/bin/env bash
grep -A1 "<DeletedObject" "$@" | grep UUID | sed -re 's:^.*<UUID>(.*)</UUID>.*$:\1:g'
#!/usr/bin/env bash
#
# KeePass export XML
# Copyright (c) 2017 Koichi OKADA. All rights reserved.
# This script is distributed under the MIT license.
#
function help ()
{
cat<<-EOD
Usage: ${0##*/} [options] KEEPASS_DATABASES ...
Options:
-h, --help help
Environment variables:
KPSCRIPT Path to KPScript
EOD
}
: ${KPSCRIPT:=KPScript}
ARGS=()
while (( 0 < $# )); do
case "$1" in
-h|--help)
OPT_H="$1"
shift
;;
*)
ARGS+=( "$1" )
shift
;;
esac
done
set -- "${ARGS[@]}"
if [ -n "$OPT_H" ]; then
help
exit 0
fi
function keepass_export ()
{
for i; do
"${KPSCRIPT}" -c:Export "$i" -pw:"${PASSWORD}" -Format:"KeePass XML (2.x)" -OutFile:"${i%.*}.xml"
done
}
PASSWORD="$(getpw.rb)"
keepass_export "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment