Welcome Guest.   Make a donation to an author on the site October 20, 2014, 04:51:17 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
View the new Member Awards and Badges page.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Thunderbird attachment processing  (Read 2381 times)
oblivion
Supporting Member
**
Posts: 354


see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« on: February 14, 2012, 05:30:34 AM »

A robot sends me emails, sometimes several times a day. The email always has an attachment (a textfile) that always has the same name, although the contents will vary (and, if everything works as it's supposed to, will never be the same twice.)

What I want to be able to do is find some means of saving those attachments into a single folder but with unique filenames.

I used to use The Bat, which could be persuaded to do something helpful in this regard. But now I use Thunderbird, so although I can make it give me a list of all the emails from the robot sender, I can't find a way to save off all those attachments in any way that's not extremely tedious.

I don't really care how they're named -- and as they're textfiles, I don't even care if they're all concatenated into a single output file. Just something I can search afterwards...

I suppose a good general purpose approach would be to name the files yyyymmddnnn.txt and maybe a hotkey trigger to paste the next filename in sequence into the "save as" editbox might be one possibility... wouldn't save all the hard work but would simplify things a lot. Better yet, though, would be the ability to take the date info from the currently selected email, but that might be asking rather a lot. Wink

Logged

-- bests, Tim

...this space unintentionally left blank.
4wd
Supporting Member
**
Posts: 3,345



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: February 14, 2012, 06:07:18 AM »

You could use the FiltaQuilla addon to add filter actions such as Save Attachments To, Detach Attachments To and Run File.

Then set a Message Filter to:
1) Match Subject/Body/etc
2) Save Attachment To <some dir>
3) Run File rename.cmd,attachment.txt

All you need to do then is knock up a command file to do the rename or a simple AHK or AutoIT script.

Here's a AutoIT script that'll take a single argument and change the filename to YYYYMMDDhhmmss.txt

eg. RenFile.exe U:\temp\attachment.txt

Formatted for AutoIt with the GeSHI Syntax Highlighter [copy or print]
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_UseUpx=n
  3. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
  4. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  5.  
  6. ; RenFile.exe <filename> [new filename, no path, no extension]
  7. ; eg.
  8. ; RenFile.exe file1.txt                 <- new file called 20120215143523.txt
  9. ; RenFile.exe file1.tmp file2         <- new file called file2.tmp
  10.  
  11. If $CmdLine[0] = 0 Then Exit
  12.  
  13. $path = ''
  14. $ext = ''
  15. If StringInStr($CmdLine[1], '\') > 0 Then
  16. $path = StringMid($CmdLine[1], 1, StringInStr($CmdLine[1], '\', 0, -1))
  17. $ext = StringMid($CmdLine[1], StringInStr($CmdLine[1], '.', 0, -1))
  18. If $CmdLine[0] = 1 Then
  19. $newName = $path & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & $ext
  20. $newName = $path & StringStripWS($CmdLine[2], 7) & $ext
  21. If FileMove($CmdLine[1], $newName) < 1 Then
  22. MsgBox(48, 'RenFile', 'Failed to rename: ' & $CmdLine[1])

Source and compiled executable attached.

You should be able to set a Message Filter similar to:


So the theory goes Wink

UPDATE: RenFile.exe will take an optional extra argument which will be the filename to rename the file to, (filename only sans extension, no path input).  No second argument will default it to YYYYMMDDhhmmss.<ext>

It retains the extension of the file passed in the first argument, so no need to add an extension to the optional second argument.

So you could change the Run File action in the message filter to, (using example above):

Run File: RenFile.exe,U:\temp\attachment.txt,@DATE@

This should rename the saved attachment to match the date string of the message.

* RenFile.zip (331.16 KB - downloaded 69 times.)
« Last Edit: February 14, 2012, 10:11:16 PM by 4wd » Logged

I do not need to control my anger ... people just need to stop pissing me off!
tomos
Charter Member
***
Posts: 8,603



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: February 14, 2012, 09:28:40 AM »

I think Attachment Extractor would cover your request - but I only use it manually (to a custom folder) so cannot say for sure.

He does give a warning on the add-on page that it might not be fully functionally.



It *is* working for me (as described) with TB 9.0.1
Logged

Tom
oblivion
Supporting Member
**
Posts: 354


see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: February 14, 2012, 01:24:15 PM »

I think Attachment Extractor would cover your request
Certainly looks promising, at first glance. I'll try this and the FiltaQuilla solutions and see what works best -- thanks, both!
Logged

-- bests, Tim

...this space unintentionally left blank.
4wd
Supporting Member
**
Posts: 3,345



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: February 14, 2012, 10:00:31 PM »

Squashed a couple of really stupid bugs in the AutoIT script and added optional second parameter.  See above.
Logged

I do not need to control my anger ... people just need to stop pissing me off!
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.128s | Server load: 0.04 ]