4 # Ensure all "dir:*"-tagged mails are in proper directories,
5 # remove all "dir:*" tags.
6 basedir="/home/plom/mail/maildir/"
7 for tag in $(notmuch search --output=tags '*'); do
8 if [ ! $(echo "${tag}" | cut -c-4) = "dir:" ]; then
11 target_dir="${basedir}"$(echo "${tag}" | cut -c5-)"/cur/"
12 for f in $(notmuch search --output=files tag:"${tag}"); do
13 new_name=$(basename "${f}" | sed -e 's/,U=[0-9]*//')
14 target_path="${target_dir}${new_name}"
15 if [ ! "${target_path}" = "${f}" ]; then
16 echo "Moving ${f} to ${target_path}."
17 mv "${f}" "${target_path}"
20 notmuch tag -"${tag}" tag:"${tag}"
23 # Remove all "deleted"-tagged files from maildirs.
24 notmuch search --output=files tag:deleted | while read f; do
29 # Sync changes back to server and update notmuch index.