#!/usr/bin/env zsh local mail_root="$(notmuch config get database.mail_root)" # copy-by-query [query...] copy-by-query() { for old_file in $(notmuch search --output=files not folder:Starred \ and not folder:Sent \ and not folder:Drafts \ and not folder:"${1}" and ${@:2}); do local name="$(basename "${old_file}")" local new_file="${mail_root}/${1}/cur/${name}" cp "${old_file}" "${new_file}" done } copy-by-query Starred tag:starred