Received: by 10.68.129.169 with SMTP id nx9mr13165059pbb.2.1330794831465; Sat, 03 Mar 2012 09:13:51 -0800 (PST) MIME-Version: 1.0 Path: h9ni35154pbe.0!nntp.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.mail.mutt From: Ulrich Thorwarth Subject: Re: macro to save attachments renamed References: User-Agent: slrn/pre1.0.0-18 (Linux) Date: Sat, 3 Mar 2012 18:13:14 +0100 Message-ID: Lines: 45 Organization: Arcor NNTP-Posting-Date: 03 Mar 2012 18:13:50 CET NNTP-Posting-Host: 3b271b98.newsspool3.arcor-online.net X-Trace: DXC=2GW[N6mO1<_V;Ef1`Jk54\McF=Q^Z^V3X4Fo<]lROoRQ8kF schrieb: > I would like to define a mutt macro to save attachments to a > particular directory with an improved filename. The following line in > my .muttrc file: > > macro attach S "$HOME/Mail/Attachments/" > > does half of what I want: it allows me to save the attachment with its > original filename to the desired directory. I would like to save the > attachment with a new filename, however, in which all spaces are > replaced by underscores, all letters are changed to lowercase, and all > single-close-quote marks are removed.* In other words, if possible I > would like my .muttrc macro to do something like execute the bash > command > > echo $filename | tr 'A-Z' 'a-z' | sed "s/'//g" | sed "s/ /_/g" > > and use the output as the new filename under which to save the > attachment in the desired directory. Is this possible? Not really the answer you want, but some ideas about it: 1) sed is fine, but have a look at filename=`echo $filename | tr -d \'\"\)\(\:\,\?\!\/\-` filename=`echo $filename | tr [:blank:] _` filename=`echo $filename | tr 'A-Z' 'a-z'` 2) I'm afraid you have to use mv for that 3) for a similar purpose I use procmail: :0 c * ^From:.*specialemailadr...@Iknowit.com |munpack -C $HOME/attachments && \ chmod 755 $HOME/attachments/*.* && \ rm $HOME/attachments/*.desc not exactly what you need, but might be an idea (this one was to save daily messages from one particular sender) 4) you probably know antiword with an autoview setting and the appropriate $HOME/.mailcap entry?? Ulrich