. /usr/local/ifmail/sets
exec >> $LOGDIR/ProcTICs.log 2>&1

dest=/home/andrej/News/out
cd /var/spool/ifmail/inb
if [ '*.[tT][iI][cC]' = "`echo *.[tT][iI][cC]`" ]; then exit; fi
for i in *.[tT][iI][cC]
do
  file=`awk '/^File/{
    l=length($2)
    if(substr($2,l,1)=="\r") f=substr($2,1,--l) 
    else f=$2
    file=""
    for(i=1;i<=l;++i){
      c=substr(f,i,1); file=file "[" tolower(c) toupper(c) "]";
    }
    print file
    next
  }' < $i`
  if [ ! -f $file ]; then continue; fi
  echo TIC: $i, FILE: $file
  mv $i $file $dest
  chmod a+rw $dest/$i $dest/$file
#  $MAIN/attach 20 -k $dest/$file $dest/$i
done
