#!/bin/bash # Read the message file path from aerc while read -r filepath; do # Get the base mail directory maildir="$HOME/.local/share/mail" # Extract the filename filename=$(basename "$filepath") # Create Trash/cur if it doesn't exist mkdir -p "$maildir/Trash/cur" # Move the file to Trash if [[ -f "$filepath" ]]; then mv "$filepath" "$maildir/Trash/cur/$filename" echo "Moved to Trash: $filename" >&2 fi done # Re-index with notmuch notmuch new >/dev/null 2>&1