Skip to content

Commit

Permalink
[scripts] cleanup mail syncing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Feb 18, 2024
1 parent 312dcee commit d1aa80e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
30 changes: 12 additions & 18 deletions scripts/.local/bin/utils/,mail-move
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
# set -e

# Move a message file while removing its UID-part
function safeMove { mv -f "$1" "$2/$(echo "$1"|xargs basename|cut -d',' -f1)"; }
safeMove() {
mv -f "$1" "$2/$(echo "$1"|xargs basename|cut -d',' -f1)"
}

# Move all archived messages from Inbox to Archive folder
echo Moving $(notmuch count --output=files 'folder:meain/INBOX' and -tag:inbox) \
archived messages from Inbox to Archive folder for personal
for i in $(notmuch search --output=files 'folder:meain/INBOX' and -tag:inbox|grep 'meain/INBOX'); do
safeMove "$i" "$MAILDIR/meain/[Gmail].All Mail/cur"
done
doMove(){
echo Archiving "$(notmuch count --output=files "folder:$1/INBOX" and -tag:inbox)" mails for "$1"
for i in $(notmuch search --output=files "folder:$1/INBOX" and -tag:inbox|grep "$1/INBOX"); do
safeMove "$i" "$MAILDIR/$1/[Gmail].All Mail/cur"
done
}

echo Moving $(notmuch count --output=files 'folder:ic/INBOX' and -tag:inbox) \
archived messages from Inbox to Archive folder for work
for i in $(notmuch search --output=files 'folder:ic/INBOX' and -tag:inbox|grep 'ic/INBOX'); do
safeMove "$i" "$MAILDIR/ic/[Gmail].All Mail/cur"
done

echo Moving $(notmuch count --output=files 'folder:mail/INBOX' and -tag:inbox) \
archived messages from Inbox to Archive folder for mail
for i in $(notmuch search --output=files 'folder:mail/INBOX' and -tag:inbox|grep 'mail/INBOX'); do
safeMove "$i" "$MAILDIR/mail/Archived/cur"
done
doMove meain
doMove ic
doMove mail
7 changes: 5 additions & 2 deletions scripts/.local/bin/utils/,mail-sync
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

# set -e

notmuch new
# fix up tags
notmuch new 2>/dev/null
,mail-move || true # move archived mails from inbox to archive

# push pull mail
if [ ! "$1" = "retag" ]; then
[ -f /tmp/mailpullfailed ] && rm /tmp/mailpullfailed
mbsync -a || touch /tmp/mailpullfailed
fi

mailtag # tag stuff with notmuch
# tag new mails
mailtag

0 comments on commit d1aa80e

Please sign in to comment.