A tough use case

So, I’m trying to plan out how to accomplish something that would be a huge help and time saver for me, as I have just left my firm job and started my own practice. I figure the folks that listen to Automators also would be a good place to get some ideas on where I can begin… if anyone has some ideas about what tool or combination of tools I can use to get this done it would get me started.

Here is my problem I’m hoping to solve:

Whenever a document is filed into a case, I receive an email notification of the filing. Within the email is a link to download a pdf version of the document. After downloading, the file needs to be renamed and then placed inside DevonThink and, from there, into a database/group for that particular case. I get between 5 and 50 of these in a day and I can spend a significant amount of time downloading, renaming, and organizing these documents everyday.

What I’m hoping to do:

I’ve setup an email account that only collects these emails. There are three different services that send me emails after a filing; the way you select the link and download the pdf is slightly different with each service. One of these services is far more prevalent, so if I could only get it working for that service, it would still be hugely beneficial.
I would like to open each email, select the link to the pdf, and download the pdf into a folder (or placed into DevonThink). From there, I would like to rename the file based upon the header within the document. That header will also tell DevonThink where to place the pdf.

Hopefully I didn’t make that too confusing. Does anyone have an idea for what tools I could use to do this? AppleScript, KM, shell script, DevonThink, etc.? Or is it not possible? I have some experience with a range of automation tools, I’m just having trouble wrapping my mind around this.

Thanks so much for any help I can get.

It is possible. Depending upon what mail client you use, you can set up rules to kick off a shell script which would download the pdf. It would help if you post the 3 different samples of the email you get. Do all the emails have 1 link to download a pdf ? Is there any user interaction required to download a pdf ? like entering a form or clicking on different popups ?
I’d break it down into multiple small steps -

  1. Can you filter the emails ?
  2. Can you setup a rule to kick off a applescript for each of that email ?
  3. parse/dump the link from the email
  4. Use a shell script to download pdf
  5. use hazel to trigger a rename and insert into DT

Regards,
Hiren

DEVONthink will actually do the sorting any way as part of its core functionality, so you could probably skip this step and have the shell script in the previous step just dump into DEVONthink for processing.

Attached are samples of the email types, the first one for Federal Court is where I get the most filings from by far. I drew an arrow next to the link that needs to be selected. After selecting the link, the pdf is automatically downloaded, so that is pretty straightforward. No interaction required beyond selecting the link.
Also, I’m using Mail.app. I have a Mac Mini setup as a dedicated DevonThink Server and I will leave Mail open on that machine so it can filter emails when they come in. If I understand the steps, they should go like this:

  1. The emails have, in part, a uniform subject line; also, this is a dedicated email address that is only provide to the courts for receiving service.
  2. Mail’s Rules has an action to kick off an AppleScript if the conditions are met, so that should be easy to setup.
  3. I’ve never done that, so I’m not positive how to accomplish it. One of the courts includes a link named “Download Document” so it is probably not hard in that case. The court I am most concerned with names the link the document number (e.g., 1, 23, 55, etc.), see the image below.
  4. I don’t know that I’ll need to do this since the pdfs download automatically when the link is selected. Is there a reason it would be beneficial to do it this way?
  5. I’ve never used Hazel to look inside the document and rename it based upon that, but I recall seeing that capability when I watched Sparks’ Hazel Field Guide.

Thanks for all the help Hiren!

Here are what the emails look like (since I’m a new user I can only post one file at a time; I’ll add the others in another post). How difficult is it to draft an AppleScript to parse the email, grab the link, and then dump it and download the doc to a set location?

Federal Court

So DevonThink would be able to read the header in the document, pull out the case number, doc number, or something along those lines, and then place the docs in a group based on that information?

That would be great, I’ve never tried to do that in DevonThink. I’ll play around with it and see if I can get it working.

Thanks!

DEVONthink has a whole feature set built in around the classification and retrieval of data. It is the classification that drives it’s ability to do the filing.