Created
April 27, 2012 22:41
-
-
Save sikachu/2514010 to your computer and use it in GitHub Desktop.
Cleanup stupid Safari bookmark duplication
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 'rubygems' | |
require 'nokogiri' | |
lines = File.open("Safari Bookmarks.html").readlines | |
urls = [] | |
output = [] | |
lines.each do |line| | |
if line =~ %r(<DT><A HREF="(.+)">.+</A>$) | |
unless urls.include? $1 | |
output << line | |
urls << $1 | |
end | |
else | |
output << line | |
end | |
end | |
File.open("output.html", "w") { |f| f.write(output.join) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment