Date Sensitive File Importer

Description

Takes a folder full of files and creates Evernote entries. It will make a new notebook named after the containing folder and the new notes are titled with their file name. The new notes use the "date created" and "date modified" as their "created" and "updated" dates. I took the bulk of the script from an old post here and updated it to recognize the date modified field, for those of us who are particular about that sort of thing.

The Code

set listOfNames to {}
set theFolder to choose folder "Select the source folder"

tell application "Finder"
    set filelist to every file of the folder theFolder
    repeat with currentFile in filelist
        set currentFileName to (the name of currentFile)
        set nom to currentFileName
        if text -4 of nom is "." then
            set currentFileName to (text 1 thru -5 of nom)
        end if
        set currentFileDate to (the creation date of currentFile)
        set modFileDate to (the modification date of currentFile)
        set currentFileLocation to currentFile as alias
        set currentFileFolder to (the name of theFolder)
        tell application "Evernote"
            set theItem to create note title currentFileName created currentFileDate notebook currentFileFolder from file currentFileLocation
            set (modification date of theItem) to modFileDate
        end tell
    end repeat
end tell

6 Responses to “Date Sensitive File Importer”

  1. Steve Jamieson July 10, 2011 at 2:28 am #

    Adam, wonderful script.

    Is there any way you can give us a choice of destination notebook? I frequently import large numbers of 2-5MB pdfs in big chunks. I would prefer to direct them to a non-synced folder just in case I don’t want them shared.

    Your current script creates a new synced notebook. Once the script starts you can’t stop EN from uploading. The folder today was a 200MB lump of a thing – 200MB wasted from my monthly quota. Would like to get into a non-synced folder then transfer the docs I want.

    Do-able?

    Many thanks.

    Steve J

  2. Michael December 17, 2011 at 2:32 pm #

    Thank you, this helped a lot.

  3. Stephen M June 1, 2013 at 1:10 pm #

    This script fails for me with the error message “Evernote got an error: Unsupported file attachment type.”

  4. matsu August 20, 2013 at 11:19 pm #

    Great work!
    I translated into japanese.
    http://matsu.teraren.com/blog/2011/04/17/mac-evernote-import/

    • Justin Lancy September 15, 2013 at 2:32 pm #

      ありがとうございました

  5. Jason H September 5, 2013 at 7:30 am #

    If you have converted to HTML instead of TXT source files, alter the numbers in the ‘if’ block, like so:

            if text -5 of nom is "." then
                set currentFileName to (text 1 thru -6 of nom)
            end if

    Source files can be found by checking your Notational Velocity or NVAlt preferences pane, but for me were at:
    ~/Library/Application Support/Notational Data/