By Sterling “Chip” Camden
Contributing Writer, [GAS]
Wait, wait, CUT! Let’s try that again, from the top.
In the trickle of tech-savvy users who’ve ditched Windows for a better computer, one question that’s asked over and over again is “How did I ever use that pig, Outlook?” — often followed immediately by “How do I get all my Outlook contacts moved over to something else?”
I recently converted to FreeBSD for my main squeeze, and decided on mutt for my new email client, based on recommendations from Chad, Mackenzie, and almost every other console-oriented *n*x geek out there. Mutt, like most good Unix programs, does one thing well: email. Its support for contact management is minimized to the concept of aliases: short names associated with full addresses, nothing more. However, there are a few choices of contact managers that work well with mutt, allowing you to look up contacts while still within mutt. One that’s specifically designed for use with mutt is abook. It’s lightweight, uses a simple text file as its database, and provides support for several import/export formats, including CSV (comma-separated values).
Outlook provides an export to CSV. While in Contacts, select “File/Import and Export…” (Office 2007).
Now, on the Unix side, you’ll need this script:
#!/usr/bin/env ruby
class String
def q
'"' + self + '"'
end
def u
self.sub(/^"(.*)"$/, '\1')
end
def c
self + ','
end
end
class NilClass
def u
""
end
def c
','
end
end
full = ''
$<.each do |line|
full += line.gsub!(/[\r\n]*/,'')
if /(,|[^,]")$/ =~ line
f = full.split /,(?=[,"]|$)/, -1
full = ''
print f[3].c + # last name
(f[2].length > 2 ? (f[1].u + ' ' + f[2].u).q : f[1]).c + # first
f[5].c + # notes (company)
(f[3].u + ', ' + f[1].u + ' ' + f[2].u).q.c + # nickname
f[31].c + # workphone
f[37].c + # phone
f[30].c + # fax
f[40].c + # mobile
f[57].c + # email
(f[8].u + ' ' + f[9].u + ' ' + f[10].u).q.c + # address
f[11].c + # city
f[12].c + # state
f[13].c + # zip
f[14].c + # country
f[87].c + f[88].c + f[89].c + f[90].c + f[91].c + # custom
"\n"
end
end
Save that as ol2ab.rb, and make sure it’s executable. Then create an intermediate csv file with this shell command:
ol2ab.rb < contacts.CSV > tmpfile.csv
That remaps the columns in the order that abook expects for its “Palm CSV” format. I chose “Palm CSV” instead of just “CSV” because it imports more fields. I also mapped “Company” to “notes”, because abook doesn’t have a Company field. For “nick” (Nickname), I combined the name fields (Last, First M). And I mapped the four user-defined fields plus the “Web Page” field from Outlook to the five “custom” fields in abook. You may also notice from the script that I account for an odd line-wrapping, the cause of which I do not know. Some lines of the Outlook-generated CSV file were wrapped on a space. So, I collect lines until they end appropriately – with either a comma or a quote, but not with the comma-quote combination. Then I split them into fields on a comma, but only if it is followed by another comma, a quote, or the end of the line. The regex-savvy amongst you readers will realize that this can be broken by a text field that ends with a comma. Oh well.
Next, run the new csv file into an abook address file. First, install abook. On FreeBSD, it’s in ports in /usr/ports/mail/abook
. Make sure that the directory ~/.abook exists and does not contain the file ‘addressbook’. Then execute this shell command:
abook --convert --infile tmpfile.csv --informat palmcsv --outfile ~/.abook/addressbook --outformat abook
Voila. Not all the fields from Outlook have been brought over, but a lot of the important ones were.
His name should be Hamburgerburglar, not Hamburglar! [Source: @goattoself]
Typical scenario in an RPG: You get at a fork om the road and can…
Teens say ‘for you’ algorithms get them right. Photo illustration by Spencer Platt/Getty Images Nora…
This affordable custom-made Darth Vader diorama lamp was hand-made by Etsy seller and artist "ResinLampMadebyRV",…
For today’s edition of “Deal of the Day,” here are some of the best deals…
SoulStop: It's like GameStop, but for your soul, where they give you a fraction of…