uuencode to attach all files in a directory

0

I am using uuencode and mail to do basic file attachments to an email.

$ path/to/targetdir/audio.gsm audio.gsm | mail user@mail.com

This works but my problem is I am trying to find a way to recursively attach all files in targetdir from the example above.

I am familiar with some shell scripting basics so I wouldnt be opposed to a solution using some shell scripting.

Thanks in advance for any help regarding the issue.

BryanK

Posted 2013-10-23T17:59:14.013

Reputation: 141

Answers

0

You could to the following:

(cd path/to/targetdir; tar czf - .) | uuencode archive.tar.gz | mail user@mail.com

The cd will change to the targetdir. The tar command will archive everthing in . (then the targetdir) and gzip it (option z) and write it to stdout (option f, "-" refers to stdout). uuencode with only one parameter reads its data from stdin instead of a file. The archive.tar.gz is the decode name.

Michael Suelmann

Posted 2013-10-23T17:59:14.013

Reputation: 578

This works really well. I appreciate the explanation of option flags too. Thanks – BryanK – 2013-10-23T18:49:29.910