Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:ressources:astuces:mutt_alias_vcard [2014/08/06 13:28] (current)
Line 1: Line 1:
 +====== Convert VCARDs into Mutt's alias format ======
  
 +The script below reads a vcard file and grabs the FN and EMAIL fields to display them into the alias format.
 +
 +It's a very simple script that will not deal with wrongly formatted VCARD files. I have used it to convert roundcube'​s contacts export into an alias file.
 +
 +
 +<​code>​
 +$ bash convert_vcard_to_alias.sh ~/​contact.vcf ​
 +
 +alias technews ACM TechNews technews@HQ.ACM.ORG
 +alias rss Contact la sauce contact@lasauceruralsoundsystem.org
 +...
 +</​code>​
 +
 +<​file>​
 +#​!/​usr/​bin/​env bash
 +#set -x
 +IFS=$'​\n'​
 +
 +tracer=0
 +nick=""​
 +long=""​
 +mail=""​
 +for line in $(grep -Ev "​^$|^#"​ "​$1"​)
 +do
 +    verb=$(echo $line|cut -d ':'​ -f 1|cut -d ';'​ -f 1| tr -d '​\r'​)
 +    case $verb in
 +    BEGIN)
 +        tracer=$((tracer + 1))
 +        ;;
 +    FN)
 +        long=$(echo $line|cut -d ':'​ -f 2| tr -d '​\r'​)
 +        ;;
 +    EMAIL)
 +        mail=$(echo $line|cut -d ':'​ -f 2| tr -d '​\r'​)
 +        nick=$(echo $mail|cut -d '​@'​ -f 1| tr -d '​\r'​)
 +        ;;
 +    END)
 +        tracer=$((tracer + 1))
 +        ;;
 +    esac
 +
 +    if [ $tracer -eq 2 ]
 +    then
 +        echo "alias $nick $long $mail"
 +        tracer=0
 +        nick=""​
 +        long=""​
 +        mail=""​
 +    fi
 +done
 +</​file>​
en/ressources/astuces/mutt_alias_vcard.txt ยท Last modified: 2014/08/06 13:28 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0