From 545019c05c8bc7e417b78396d1aa44b49781e9e0 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 13 Mar 2021 07:44:11 -0800 Subject: [PATCH] update_lists handles different mail directories --- update_lists | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/update_lists b/update_lists index d398991..6f7548f 100755 --- a/update_lists +++ b/update_lists @@ -1,17 +1,17 @@ #!/bin/bash -for listdir in lists bugs; do - ( cd ~/Maildir; - find $listdir -maxdepth 1 -mindepth 1 -type d | \ - perl -ne 'chomp; $a = $_; $b = $a; $b =~ s/\./_/g; $b =~ s/\//./g; qx(ln -sf "$a" ".$b")'; - ); - ( cd ~/Maildir/$listdir; - find . -maxdepth 1 -mindepth 1 -type d| \ - xargs -n 1 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"'; - ); -done; +set -e -# Remove broken symlinks -(cd ~/Maildir; - find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete; -); +for maildir in Maildir Mail; do + if ! [ -e ~/$maildir ]; then + continue + fi; + ( cd ~/$maildir ; + for listtype in lists bugs; do + find . -maxdepth 1 -mindepth 1 -type d -iname "$listtype"'.*' -print0| + xargs -0 -i bash -c 'A={}; (( $(find "$A" -type f -name "*" -not -name "dovecot*" -not -name ".imap*" -not -name ".customflags" | wc -l) == 0 )) && rm -rf "$A"'; + done; + find . -maxdepth 1 -mindepth 1 -type l -iname '.*' -not -xtype d -delete; + ); + exit 0; +fi; -- 2.39.2