Tuesday, June 11, 2013

Sending all files in a folder over SMTP

A while ago I was looking for how to back up all the data in my hard disk on email ID. I could have attached all files in emails (multiple files in a single mail with explanation in body) but that would be too hectic and only reasonable for a selective dump. If I wanted to upload, for example, all my music... I needed something automated.

Command line has always been easier to be included in hacks and codes to get your work done with elegance. I searched for an command line email program (as a replacement for a normal GUI email program) and used my university server to upload it all.

Now all I had to do was create a .bat file and place it in the same folder with all my files in it and executing it would do the rest. I chose Febooti Mail - a trial version still did the trick (even though it had a signature saying it was a trial version at the end of each mail... but who cares).

This is the .bat code I wrote for it:

@echo on

rem sending all files in the folder as attachments. one attachment per email...

for %%i in (*.*) do Febootimail -smtp -to my.backup.id@gmail.com -from my.registration.no@giki.edu.pk -debug -subject %%i -ATTACH %%i

This was elegant, each mail had one attachment with it and the file name as the subject. Much easier to search through my personal backup using gmail search. Now that I was receiving all my files at gmail, I had to set up a simple filter to tag it with a label and 'archive' it so that my inbox was not flooded.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.