#!/usr/bin/bash
# attach multiple files thunderbird.sh
#thunderbird -compose "attachment='file:////home/will/newfile,file:////home/will/newfile2'"
#-compose subject=Emailing %m,attachment=%u

if [ $* = "" ] ;then echo "no files given" ; exit 1 ;fi  &>/dev/null
Y=`echo file://$* | sed 's/ \//,file:\/\/\//g' | sed 's/ /^^/g'`   #this sed replaces all spaces with a ^^.
X=`echo $Y | sed 's/\^^/ /g'`            #this sed replaces all ^^'s with a space
Z=`echo $Y | sed 's/,file:\/\// /g'`
ii=1                        #that sed (below)replaces all ^^'s with a space
BODY=$(for file in $Z ;do C=`basename "$(echo $file | sed 's/\^^/ /g')"` ; echo ; echo -n "$ii) $C" ;  ii=$(($ii+1)) ; done)
thunderbird -compose "attachment='$X'"
#thunderbird -compose "attachment='$X'",body="P.S. - Attached Files:  $BODY",subject="attached files"
exit 0
