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