Jump to content

AppleScript to support/enhance FileThis imports


Recommended Posts

So after having heard about it several times but never finding time to delve further into it, I finally signed up for FileThis (http://filethis.com) and connected several of my accounts to be automatically imported to Evernote. I was blown away by how straightforward the process was. It brought in the backlog of statements from my banks, credit cards, utilities, health insurance, and even Amazon.com orders, and will continue to do so automatically moving forward (by default, in the free tier, once per week.)


The one major issue I had was that the creation/modified dates of the notes that were created were the date/time of the import into Evernote, not the dates of the statements themselves.  The problem was exacerbated by the fact that many of the statements did not seem to be imported in chronological order (so, for instance, a statement from Dec 2012 appeared near the top of the list, while Mar 2014 was rather toward the bottom) and it seemed to be rather random.  Not a huge deal for Premium subscribers, since they're searchable, but an annoyance nonetheless.


After noticing that all of the PDF attachments were similarly formatted in their filenames, all including a YYYY-MM-DD format date, I wrote an AppleScript that went through and updated all of the create/modified dates of the FileThis-created notes to mirror the dates in the filenames.  In order to make it flexible, I did use regular expressions, so you may need to download and install the Satimage osax extension (http://www.satimage.fr/software/downloads/Satimage392.pkg) in order to enable this capability.  After that it's really quite straightforward.  Including code here, since attaching AppleScript files is disallowed:

tell application "Evernote"  set statements to find notes ("tag:FileThis")  repeat with statement in statements    set att to attachment 1 of statement    set fname to filename of att    set datestring to find text "[0-9]{4}-[0-9]{2}-[0-9]{2}" in fname with regexp and string result    set yyyy to text 1 thru 4 of datestring    set mm to text 6 thru 7 of datestring    set dd to text 9 thru 10 of datestring    set new_date to my date (mm & "/" & dd & "/" & yyyy & " 12:00:00 AM" as string)    set creation date of statement to new_date    set modification date of statement to new_date  end repeatend tell

Save into a file (e.g., EN-filethis-fixdate.applescript) and then it can be run from the terminal like so:

osascript EN-filethis-fixdate.applescript

This will update the information directly in your local application, which will then be synced to the cloud and across all of your devices.  


And your list ordering will be sane again, and your OCD can rest.

Link to comment
  • 2 weeks later...



I noticed that FileThis always saves the statement to a note with title that follows the pattern:


<account name> <account number> <date>.pdf


Would it be easier to just parse the note title, rather than search within the attachment?  If so, then  you would not need a regular expressions, just the last 14 characters of the note title.


Instead of (or in addition to) modifying the creation date, I would find it more useful to rename the note title with the the date first rather than last.  Could you show how to do that with Applescript?





Link to comment
  • 2 weeks later...

Hi Saverio,


The regex is preferred, because although it does generally put date last, if there are two documents from the same date, it appends an additional number (e.g., Amazon My Orders 2014-05-20 1.pdf).  The regex approach should be more robust.


As far as changing the title, you can simply use the "title" attribute.  Adding something like these two lines at the bottom of the script should do the trick:

set filestring to find text "[^0-9]+" in fname with regexp and string resultset title of statement to datestring & " " & filestring

This sets the 'filestring' variable to the attachment's filename, up to the first occurrence of a digit.  It then sets the note title to the YYYY-MM-DD datestring found earlier in the script, prepended to the filestring.  You can mess around with it to get the titles just as you prefer.

Link to comment
  • 3 years later...

What about teaching Evernote to auto-tag with tags of my choosing? It creates tags with <company name> <company name account number> <"FileThis">. But what if I have a different system and want it to be tagged with tags like: "Financial," "Taxes 2017" etc.?

Link to comment
  • Level 5*
3 minutes ago, rebREorg said:

What about teaching Evernote to auto-tag with tags of my choosing? It creates tags with <company name> <company name account number> <"FileThis">. But what if I have a different system and want it to be tagged with tags like: "Financial," "Taxes 2017" etc.?

I use Applescript to assign tags to my notes.

Link to comment
  • Level 5*
On 2017-07-28 at 오전 8시 32분, rebREorg said:

I guess I knew that'd be the answer... but what if I have no idea how to use Applescript?

I don't want to hijack this discussion
If you post in the Mac forum, you can get more details on using Applescript with Evernote

Here's an example from one of my scripts

else if (offset of "SHAW CABLE" in note_Detail) > 0 then
        copy "?Vndr-Shaw" to end of

tell application "Evernote" -- Create the note --------------------------------
new_Note to (create note with text "Scotiabank Chq" title note_Title notebook "Filing?")
creation date of new_Note to date (characters 1 thru 10 of note_Title as string)
                assign note_Tags to new_Note
            end tell

As a start to learning AppleScript

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...