rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | README | LICENSE

rpdedup (776B)


      1 #!/bin/sh
      2 
      3 set -x
      4 
      5 if [ $# -lt 4 ];
      6 then
      7 	printf "usage: %s cfgfrom folderfrom\n" \
      8 		"$(basename $0)" >&2
      9 	exit 1
     10 fi
     11 
     12 cfg="$1"
     13 fold="$2"
     14 
     15 tmpfile="$(mktemp)"
     16 rpview -ve message-id -c "$cfg" -m "$fold" : > "${tmpfile}"
     17 
     18 tmpfilesu="$(mktemp)"
     19 cat "${tmpfile}" | sort | uniq -d  > "${tmpfilesu}"
     20 
     21 uuid=$(uuidgen)
     22 uuidseq="${uuid}seq"
     23 uuidtmp="${uuid}tmp"
     24 
     25 cat "${tmpfilesu}" \
     26 	| while read -r line;
     27 do
     28 	rppick -qe "$uuidtmp" -c "$cfg" -m "$fold" :header message-id "${line}"
     29 	if [ -z "$(rpmark -vc "$cfg" -m "$fold" "$uuidtmp" \
     30 			| cut -d' ' -f 3 )" ];
     31 	then
     32 		rpmark -c "$cfg" -m "$fold" -a "$uuidseq" "${uuidtmp}[0]"
     33 	fi
     34 done
     35 
     36 if [ -n "$(rpmark -vc "$cfg" -m "$fold" "$uuidseq")" ];
     37 then
     38 	rprm -c "$cfg" -m "$fold" "$uuidseq"
     39 fi
     40 
     41 rpmark -d "$uuidseq"
     42 rpmark -d "$uuidtmp"
     43