Evernote watched folders on OS X

Following on from the send to Evernote addition for Evernote I also wanted to reproduce the Windows Evernote watched folders feature.  This allows a file moved to a specific folder to be automatically imported into a new note within Evernote and again can be accomplished with AppleScript.

The script to import the file into Evernote should be attached to the folder.  Right click on a folder and select “Folder Actions Set-up…” to access the naming and specifying for the folder’s action.

The script is heavily based upon the send-to processing in the previous post so if you’re interested in some of the details please have a read of that too.

on adding folder items to this_folder after receiving these_items
    
    repeat with anItem from 1 to number of items in these_items
        set this_item to item anItem of these_items
        set the item_info to info for this_item
        set the item_path to this_item as text
        
        tell application "Evernote"
            try
                create note from file this_item notebook "Auto Import"
            on error error_message number error_number
                
                if the error_number is equal to 4 then
                    -- The file being imported is not supported
                    set userCanceled to false
                    try
                        display dialog "Your Evernote account does not support the import of this type of file.  Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution
                    on error number -128
                        set userCanceled to true
                    end try
                    
                    -- If the user wishes they can be taken to the Evernote premium upgrade page
                    if userCanceled is false then
                        tell application "Safari"
                            activate
                            open location "https://www.evernote.com/Checkout.action"
                        end tell
                    end if
                else
                    -- Unspecified failure
                    display alert "Import into Evernote failed" message "Error(" & error_number & "): " & error_message as warning
                end if
            end try
        end tell
    end repeat
end adding folder items to

beep 1

I use an unsynchronised notebook called “Auto Import” to take in files dropped into my particular watched folder. This means that I don’t arbitrarily use up my monthly quota. You should amend this to the name of whatever notebook you would like to import to.

Author: Stephen Millard
Tags: | applescript | evernote |

Buy me a coffeeBuy me a coffee



Related posts that you may also like to read