[EN] Bash scripts & Apple Mail (.emlx files)

Introduction
Apple Mail 3.6 is the default e-mail client for Mac OS X Leopard. It’s a very good client, with tons of unique features (such as smart folders) but if you need to go advanced, well… you need the power of Bash shell and some command-line kung-fu.

The really cool stuff about Apple Mail is that it saves e-mails as multiple .emlx files (one .emlx file = one e-mail), instead of compressing all your mailbox inside a big, chunky, bloated .mbox file like many other clients do. The .emlx approach slows up a lot Apple Mail when you get a big mailbox (20000+ mails), but it’s easy to deal with it via Bash scripts.

I made four handy Bash scripts to deal with Apple Mail. The posts are written in italian, but the sourcecodes (comments, error messages, variable names..) are written in english. You have to provide the path to your mailbox folder to some of these scripts , so change the “mail_folder” variable according to your needs before executing the scripts. To run the scripts, launch the Terminal and type something like (change the script name according to your needs):


chmod +x mail2topwordlist.sh
sh mail2topwordlist.sh


mail2topwordslist.sh:

This script extract all the words from your e-mails bodies and create some lists out of them, in the following form:

492 Ospedale
254 sedia
120 ghb
118 cannabis

and

Ospedale,492
sedia,254
ghb,120
cannabis,118

The number is the frequency of the nearby word. The second list is in CSV format, so you can import it inside Excel or similar, and get some statistics out of it.

Post & sourcecode here

mail2subjectslist.sh

This script generates both a “raw” and a sorted list of the most frequent subjects and replies. The raw list:

[eldino's Shock News] Addio a Gary Coleman il piccolo Arnold della tv
Re: [eldino's Shock News] Addio a Gary Coleman il piccolo Arnold della tv
Re: [eldino's Local News] Japan in love (Ancona)
Re: [eldino's Local News] Japan in love (Ancona)
Re: [eldino's Fun Pics] Cat iPad stand

and the sorted list:

2 Re: [eldino's Local News] Japan in love (Ancona)
2 Re: [eldino's Fun Pics] Cat iPad stand
1 [eldino's Shock News] Addio a Gary Coleman il piccolo Arnold della tv
1 Re: [eldino's Shock News] Addio a Gary Coleman il piccolo Arnold della tv

This script is very handy if you use Gmailgroup mails by thread” built-in function a lot.

Post & sourcecode here

mail2book.sh:


This script collects all the e-mails with subjects starting with the same label and create a book out of them. For example, thi script is handy if you get tons of e-mails labeled as “[Pink News]“, such as:

[Pink News] Puntata #1
[Pink News] Puntata #2
[Pink News] Puntata #3
[Pink News] Puntata #4
[Pink News] Bonus estate

where “[Pink News]” could be whatever label of your choice.

Post & sourcecode here

csv2cloudtext.sh:

This script converts a CSV list in the following form:

inutile,5
microcefalo,3
tronista,2
violenza,1

to a cloud text like:

inutile
inutile
inutile
inutile
inutile
microcefalo
microcefalo
microcefalo
tronista
tronista
violenza

that you can copy & paste into tag cloud generation services like Tagcrowd.com. This script is very handy if used together with mail2topwordslist.sh to obtain a graphical map of the frequency of your words.

Post & sourcecode here

About these ads

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

Iscriviti

Ricevi al tuo indirizzo email tutti i nuovi post del sito.

Unisciti agli altri 76 follower

%d blogger cliccano Mi Piace per questo: