Last active
July 16, 2020 04:13
-
-
Save zerobase/2c6b36fa6c7c30ae783458cd3e97b9ae to your computer and use it in GitHub Desktop.
Safari Readling List to Instapaper CSV (Ruby script for Mac)
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
# 1. Open Terminal.app. | |
# 2. Type "cd Desktop" and Enter. | |
# 3. Type "open ~/Library/Safari/" and Enter. | |
# 4. Hold Option key and drag-and-drop (i.e. copy) Bookmarks.plist 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 Safari-Reading-List.csv on 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 | |
e["URLString"], | |
e["URIDictionary"]["title"], | |
nil, | |
"Unread" | |
] | |
} | |
end | |
File.open("Safari-Reading-List.csv", "w") do |f| | |
f.puts "URL,Title,Selection,Folder" | |
f.puts csv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment