summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-28 01:50:25 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-28 01:50:25 -0500
commitbc871dbc38d4e1729bfe8696bac0eb86b4d8b7b8 (patch)
treeac44a9fd627df6af11dbf8341016e84428829a18
parentaf58e68243f3b6b10d7dd177f54c55c3f379ee92 (diff)
write maildups
a tool to delete duplicate emails in a mailder based on the Message-ID header
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rw-r--r--maildups.sh11
3 files changed, 13 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index ad1cfdc..cd6b837 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ e
emacsmail
emacsterm
hangman
+maildups
newegg
offlineimap-runner
ord
diff --git a/Makefile b/Makefile
index 89d25f6..d063078 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ BINFILES = \
emacsmail \
emacsterm \
hangman \
+ maildups \
newegg \
offlineimap-runner \
ord \
diff --git a/maildups.sh b/maildups.sh
new file mode 100644
index 0000000..d5521da
--- /dev/null
+++ b/maildups.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Delete duplicate messages in $1 based on the Message-ID header
+
+maildir=$1
+
+msgid_file=`mktemp`
+grep -rH -m1 '^[Mm]essage-[Ii][Dd]:' "$maildir"|sort -n>"$msgid_file"
+
+< "$msgid_file" sed 's/:.*//'|uniq -d|while read msgid; do
+ sed -n "s/^$msgid://p"|sed 1d|xargs -d'\n' rm -f
+done