Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Safari Readling List to Instapaper CSV (a ruby script for macOS)
# 1. Open Terminal.app.
# 2. Type "cd Desktop" and Enter.
# 3. Type "open ~/Library/Safari/ ." and Enter.
# 4. Copy `Bookmarks.plist` file to the Desktop.
# 5. Back to the Terminal, type "ruby safari-readling-list-to-instapaper-csv.rb" and Enter.
# 6. Open Instapaper Settings (https://www.instapaper.com/user), and select "Import from Instapaper CSV."
# 7. Upload `instapaper-import.csv` from the Desktop.
require "plist"
require 'csv'
csv = CSV.generate do |csv|
bookmarks_xml = `plutil -convert xml1 -o - Bookmarks.plist`
Plist.parse_xml(bookmarks_xml)["Children"].select{ |e|
e["Title"] == "com.apple.ReadingList"
}[0]["Children"].map{ |e|
csv << [ # URL,Title,Selection,Folder,Timestamp
e["URLString"],
e["URIDictionary"]["title"],
nil,
"Unread",
Time.now.to_i
]
}
end
File.open("instapaper-import.csv", "w") do |f|
f.puts "URL,Title,Selection,Folder,Timestamp"
f.puts csv
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment