#!/usr/bin/env sh # Archive files that are NOT tagged Inbox accounts="david.julien@univ-nantes.fr" # Update paths & tags notmuch new --no-hooks filter() { notmuch search --output=files --format=text0 $parameters and tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/new/" notmuch search --output=files --format=text0 $parameters and not tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/cur/" } for account in $accounts do tags_location="$XDG_CONFIG_HOME/notmuch/tags/$account" tags="$(grep "+" "$tags_location" | sed -e 's/^.//' -e 's/ .*//')" for tag in $tags do [ "univ" = $tag ] && continue parameters="folder:$account/INBOX and tag:$tag" filter done done # Update paths notmuch new --no-hooks