Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 05, 2015, 11:17:07 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Thunderbird attachment processing  (Read 2777 times)

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 386
    • View Profile
    • Donate to Member
Thunderbird attachment processing
« 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. ;)

-- bests, Tim

...this space unintentionally left blank.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,976
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Thunderbird attachment processing
« 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

Code: AutoIt
  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:
2012-02-14_23-35-29.jpg

So the theory goes ;)

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.
« Last Edit: February 14, 2012, 10:11:16 PM by 4wd »

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,525
    • View Profile
    • Donate to Member
Re: Thunderbird attachment processing
« 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.

Screenshot - 2012-02-14 , 16_27_00.pngThunderbird attachment processing

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

oblivion

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 386
    • View Profile
    • Donate to Member
Re: Thunderbird attachment processing
« 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!
-- bests, Tim

...this space unintentionally left blank.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,976
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Thunderbird attachment processing
« 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.