Skip to content

Instantly share code, notes, and snippets.

@zeeshankhan
Last active July 16, 2020 04:33
Show Gist options
  • Save zeeshankhan/11e178f2d6ab4fa9027f22e1c4f808fc to your computer and use it in GitHub Desktop.
Save zeeshankhan/11e178f2d6ab4fa9027f22e1c4f808fc to your computer and use it in GitHub Desktop.
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