#!/usr/bin/env ruby -w # delicious2yojimbo.rb by Ben Kerney, ben.kerney@gmail.com # Based on delicious2yojimbo.pl by Marcus Kazmierczak, marcus@mkaz.com # and Manton Reece, http://www.manton.org/, which, when I downloaded it on # 2009-05-16, was not working for me. # Rather than troubleshoot, I rewrote it in Ruby. # TODO: support multi-word tags, report actual success of import # ============================================================================ # A simple script to import del.icio.us bookmarks, with tags, into Yojimbo # No syncing, or any fancy stuff. Intended as a one time deal. # Step 1: # Got to: https://api.del.icio.us/v1/posts/all?user=YOURNAME # Replacing YOURNAME with your del.icio.us username # Login using your del.icio.us account # save file to your desktop called: all.xml # Step 2: # If you haven't done so already, save the delicious2yojimbo # script to your desktop (or same location as all.xml) # Step 3: # From the terminal/x11/command-line run the script # ruby delicious2yojimbo.rb filename = "all.xml" lines = File.new(filename) i = 0 strip = "'" # characters that interfere with the command line lines.each do |line| if line =~ /.*href="(.*?)".*description="(.*?)".*tag="(.*?)".*/i href, desc, tag = $1.tr(strip,""), $2.tr(strip,""), $3.tr(strip,"") puts "#{href} :: #{desc} :: #{tag} \n " as_cmd = "tell application \"Yojimbo\"\n" as_cmd += "set the_item to make new bookmark item with properties {name:\"#{desc}\", location:\"#{href}\", comments:\"\"} \n" as_cmd += "add tags (words of \"#{tag}\") to the_item \n" as_cmd += "end tell" result = `osascript -e '#{as_cmd}'` i += 1 end end puts "Imported #{i} Bookmarks \n"