The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

Create people files automatically

Contributed by: Marco Nelissen
This tip is valid for: Both BeOS and Haiku

The following script will parse all the email messages in your inbox, generating
a People file with name and email-address for each person who sent you a
message. Existing People files with the same name will not be clobbered.

[Editor’s note: If you use Mail-It and want to be more selective about this process, just click the sender’s email address in the header pane to add that person to your People database quickly.]



cd ~/mail/in
find . -type f | {
read file
while [ "$file" != "" ]
do
  NAME=$(catattr MAIL:name "$file")
  NAME=$(echo $NAME|awk '{print $3}' FS=" : ")
  if [ "$NAME" != "" ]
  then
    EMAIL=$(catattr MAIL:from "$file")
    EMAIL=$(echo $EMAIL|awk '{print $2}' FS="<")
    EMAIL=$(echo $EMAIL|awk '{print $1}' FS=">")
    if [ "$EMAIL" != "" ]
    then
      FILE=/boot/home/people/$NAME
      if [ ! -f "$FILE" ]
      then
        touch "$FILE"
        addattr -t string BEOS:TYPE application/x-person "$FILE"
        addattr -t string META:name "$NAME" "$FILE"
        addattr -t string META:email $EMAIL "$FILE"
        echo $NAME : $EMAIL
      fi
    fi
  fi
  read file
done
}

Posted in Miscellaneous


(comments are closed).