summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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