Created
May 6, 2014 14:45
-
-
Save dentarg/5656b8d078e8cfb8dcf3 to your computer and use it in GitHub Desktop.
KeePass 2 XML export to 1Password Mac CSV import http://learn2.agilebits.com/1Password4/Mac/en/KB/import.html
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
require 'csv' | |
require 'open-uri' | |
require 'nokogiri' | |
file = "keepass.xml" | |
doc = Nokogiri::XML::Document.parse(open(file)) do |config| | |
config.noblanks | |
end ; nil | |
entries = [] | |
doc.css('Group > Entry').each do |entry| | |
attributes = {} | |
attributes["GroupName"] = entry.parent.css('> Name').text | |
entry.css('String').each do |string| | |
unless string.css_path.include?('History') | |
key = string.css('Key').text | |
value = string.css('Value').text | |
attributes[key] = value | |
end | |
end | |
entries << attributes | |
end | |
content = entries.map do |entry| | |
[ | |
"#{entry['GroupName']} #{entry['Title']}", | |
entry['URL'], | |
entry['UserName'], | |
entry['Password'], | |
entry['Notes'], | |
] | |
end | |
CSV.open("1password.csv", "wb") do |csv| | |
content.each do |row| | |
csv << row | |
end | |
end |
worked like a charm. Thanks a bunch!
Works good! Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this script, works like a charm from KeePass2 to 1Password 5!