Save Attachments to Special Folder in Mutt

Problem: How to save attachments in mutt?

No built-in solution for save multiple attachments to special folder in mutt. I spent couple hours to develop a workflow for doing this.


  • In muttrc:
macro attach s "<shell-escape>~/.config/mutt/bin/\n:source /tmp/from\ns" "Save attachment to specific folder"
macro attach S "<shell-escape>~/.config/mutt/bin/\n:source /tmp/from\ns" "Save attachment to specific folder"
  • Shell script in ~/.config/mutt/bin/

if [[ -e /tmp/from ]]; then
    rm /tmp/from
echo $HOME"//" > /tmp/from
nvim "+normal G$" +startinsert /tmp/from
path=`cat /tmp/from`
echo $path
if [[ !(-d $path) ]]; then
    mkdir -p $path
echo 'macro attach s "<save-entry><bol>'$path'\n"' > /tmp/from

How to Use

  1. in mutt, goto attachment page, save attach by type s;
  2. nvim will show up with file of /tmp/from
  3. Finish the path in nvim, I use nvim here is because of the path auto completetion feature.
  4. Exit nvim, the select attachment will be save to the specified path automatically, and will go to the next attachment item;
  5. Press s again for saving the following attachments.
Ming Su
Ming Su
Associate Professor of Environmental Engneering

My research interest is water quality problems in drinking water bodies, with a focus on harmful algal blooms and associated taste & odor problems.