nsbin/fix-maildir-mbsync-duplicate-uid
Nico Schottelius 18d05d9b37
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
updated by /home/nico/bin/sync-all-repos on nb3
2024-05-08 13:36:17 +02:00

27 lines
596 B
Bash
Executable file

#!/bin/sh
# Nico Schottelius, 2024-05-08
# Can also be run in a loop with:
# for uid in $(find . | grep -o 'U=.*:' | sort | uniq -d | sed -e 's/U=//' -e 's/:$//') ; do fix-maildir-mbsync-duplicate-uid $uid; done
if [ $# -ne 1 ]; then
echo $0 UID
echo "Remove the UID from the newer message"
fi
MAIL_UID=$1
i=0
for mail in $(ls *U=${MAIL_UID}:*); do
i=$((i+1))
# Do not rename the first one
if [ $i = 1 ]; then
continue
fi
# Rename all others
new_name=$(echo $mail | sed 's/,U=.*//')
echo "Renaming $mail to $new_name"
mv $mail $new_name
done