Jump to content
  • 0

(Archived) TIP: Creating an auto-import folder using Folder Actions


geechorama

Idea

If you want to set up an auto-import folder for the Mac Evernote client, here's what you need to do:

- First up, you want to create the auto-import folder in the Finder. For this guide, we'll create a folder on the Desktop called "Evernote Auto-Import".

- The next step is to enable Folder Actions. Right click on the auto-import folder and choose "Enable Folder Actions":

post-8182-131906062513_thumb.jpeg

- Now, we want to make a script. Create the script using Script Editor and save it in "Library/Scripts/Folder Action Scripts" Our script will look like this:


--
-- Folder Action script to add items to Evernote when they appear in a folder
--

-- after clipping, we'll move files into here
property done_foldername : "Clip Successful"
-- if the clip fails, we'll move files into here
property failed_foldername : "Clip Failed"

on adding folder items to this_folder after receiving these_items
try
-- iterate of files added
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
tell application "Evernote"
-- clip it!
create note from file this_item title "Auto Import " & this_item
end tell
tell application "Finder"
-- make sure our 'success' destination folder exists
if not (exists folder done_foldername of this_folder) then
make new folder at this_folder with properties {name:done_foldername}
end if
set done_folder to folder done_foldername of this_folder
-- move the file we just clipped into our success folder
move this_item to done_folder with replacing
-- all done
end tell
end repeat
on error e
-- uh oh. bad things happened.
tell application "Finder"
-- make sure our 'failed' folder exists
if not (exists folder failed_foldername of this_folder) then
make new folder at this_folder with properties {name:failed_foldername}
end if
set failed_folder to folder failed_foldername of this_folder
-- move the failed file into the failed folder
move this_item to failed_folder with replacing
-- display the error message
display dialog e buttons {"Cancel"} default button 1 giving up after 120
end tell
end try
end adding folder items to

- Finally, link up the folder and the script by right-clicking on the auto-import folder and choosing "Attach a Folder Action..." from the menu:

post-8182-131906062515_thumb.jpeg

Now choose the script we just created, and that's it! Yer ready to go. Drag an image or file into the folder to try it out. If the clip is successful, the file gets moved into a sub-folder called "Clip Successful", and if it fails, it goes into a sub-folder called "Clip Failed" and the Finder will display the error message.

Link to comment

63 replies to this idea

Recommended Posts

There are some good scripts here. I made my own to fit some custom requirements I have.

I use Evernote & Dropbox on my iPad and iPhone quite a bit. I also use GoodReader and a few other apps that sling files around that I want to keep in Evernote for various purposes.

I've set up my Mac to run this Folder Action everytime it sees a file in my Dropbox's "Import to Evernote" folder, so wherever I am I can import directly into Evernote regardless of file type to Evernote, then it is there and I can use the iPhone/iPad client to edit the notes to my specifications (e.g. I can add any file type, etc from GoodReader using its any web url download capability on the iPad or iPhone).

It also detects if Evernote is running on my Mac, if it is already running does leaves it running when it is done, if it has to launch it, it closes it, so it cleans up well after itself (it also deletes the file out of the hot folder).

Works really well for what I want it to do. YMMV.

Download the Folder Action from https://www.dropbox.com/s/73wvlz0qq6ykgg0 and edit/assign it to the appropriate folder you'd like to be the hot folder.

Link to comment

You can just call me "Justin"! ;)

I don't have a version like that but, as always, I am happy to tailor scripts to individual workflows.

If anyone is interested, you can fill out this form with as many specifics as possible:

http://veritrope.com/about-veritrope/custom-scripts-and-workflows/

I'll take a look and get back to you with an estimate.

======================

Back to the published script for a moment -- I've been getting a lot of downloads, but not a lot of comments. Anyone else try it? Thoughts/suggestions/etc. are welcome on the script's page (link in my earlier post), on Twitter, or via the Veritrope.com Contact page!

Link to comment

Veritrope - do you have a version that would just add to a pre-assigned folder (set within the script) or to the default folder but without the requirement of user input via the dialogs? i have someone adding docs for me via a synced Dropbox folder and I want these docs to go directly to Evernote even when I am not around.

Link to comment

Hi,

Could this script be changed so that it would add either "Spotlight comments" or OpenMeta tags as tag information into the new note? Or if possible both :)

I'd prefer OpenMeta anyway, because it's a real tagging environment that is included with the files and not in the .DS_Store....

Link to comment

Questionon location in evernote & note title.

I was able to edit the script to remove the Auto Import part of hte title but I can't see how to use just hte filename as a title. Is it possible? I see this was asked earlier but no answers I could see.

Second issue, Is there a way to tell evernote where to put the resulting clipping? i.e a specific notebook?

Link to comment

Hello,

First of all, let me say that this is a great script and ALMOST fits my needs perfectly. My workflow for scanning documents is as follows:

1. My PA puts the document on the scanner and then presses the Scan button.

2. The document is saved into a folder, at which point the application Hazel moves the file to the folder where your script is run as a folder action.

3. The script works perfectly and sorts the file into the Clip Successful folder.

All that is hunky-dory, my problem is that my scanner software only lets me use the same name for each document scanned, if I want to do it automatically that is. There is is no way to sequentially outnumbers to each document. This means that when your script sorts the file into the Clip Successful folder, if the file already exists, it overwrites it.

I would like to keep a copy of my documents separate from Evernote, so you can see why this behaviour would be a problem. Is there any way of modifying the script so that it avoids this problem?

Just FYI, the reasonable needs to be automatic is that I am quadriplegic and therefore cannot fill in different details for each document on a document like document basis.

I hope this makes sense!

Link to comment

Should this script work in Snow Leopard?

At the point of compiling, I am getting an error message: Expected end of line, etc. but found application constant or consideration. At that point, I can't save it as a .scpt.

Link to comment

If you're dragging a file, then this is basically the same thing. It can be useful if you have some application (e.g. a scanner) that drops files into a folder, however. This may save you a step.

Link to comment
Why isn't this supported within the program itself? It's unacceptable to pay $45 for a premium account and not have something so basic supported

hear! hear!

First, the post you quoted was posted primarily as spam b/c of the links included in the post (and that you included in your quote) and has been deleted.

Second, I've perused this thread & don't understand what "basic" feature you're saying isn't supported. Admittedly, I didn't read every detail, but AFAIK, import folders are supported on Mac.

Link to comment
  • Level 5*
Why isn't this supported within the program itself? It's unacceptable to pay $45 for a premium account and not have something so basic supported

hear! hear!

First, the post you quoted was posted primarily as spam b/c of the links included in the post (and that you included in your quote) and has been deleted.

Second, I've perused this thread & don't understand what "basic" feature you're saying isn't supported. Admittedly, I didn't read every detail, but AFAIK, import folders are supported on Mac.

If they are BnF, I can't find them. Nevertheless, it looks like Veritrope's script does exactly the same thing.

Link to comment

For those of you trying to create the note with just the name of the file, I just figured out how to do it (replace the "create note" line with this):


create note from file this_item title do shell script "basename " & quoted form of POSIX path of this_item

jessica

Link to comment

I left Windows for Mac just to avoid this sort of roll-your-own solution, and my guess is that the EN developers recognize this and will bring the Mac version up to the Windows capabilities pretty soon. After all, auto-import is more or less the default method of getting scans into EN Windows.

Link to comment

If they are BnF, I can't find them. Nevertheless, it looks like Veritrope's script does exactly the same thing.

it does not right? Evernote for windows keeps track of the files dropped in the folder so it only imports the newer ones... this script imports new files into evernote but then it sends the file to the trash :(

Link to comment

The nice thing about AppleScript is that it's pretty easy to make it do **EXACTLY** what you want it to do! :(

For example -- To keep the script from deleting the files, all you have to do is remove this line of code:


tell application "Finder" to delete added_items

For future revisions of the script, I'll probably include some "switches" to make customization even easier.... but hope this helps for now!

Link to comment
The nice thing about AppleScript is that it's pretty easy to make it do **EXACTLY** what you want it to do! :)

For example -- To keep the script from deleting the files, all you have to do is remove this line of code:


tell application "Finder" to delete added_items

For future revisions of the script, I'll probably include some "switches" to make customization even easier.... but hope this helps for now!

Hi there,

yeah, I know I know... yesterday evening I spent a couple of hours playing around with your script! :)

But the thing is, I just feel I'm starting to go back to my linux days seeking Evernote for Mac to enable me do things that Evernote for Windows actually does out of the box.

Back when I had Windows XP, I had several "import folder" profiles. I would then have the software of my scanner store the scanned files in one of the watched folders and Evernote would do the rest, keeping track of the things that had already been imported before... I would swear that even if the filename was changed, Evernote would not reimport the file (I'm not sure though), suggesting that Evernote keeps a database somehow I guess...

What I want to say is that you can get really far with scripting, I know (have used debian for years), but I feel somehow that Mac users in this case have been left out for this and other features should be provided by Evernote itself.

Thanks a milion for your extremely helpful script and for your prompt answer (gotto post this very same answer on your original post)

Marc

Link to comment

I have edited Veritrope's script"

1. removed the dialogue - set Tag to blank and the default notebook to one of my choice

2. added file un-lock function

3. added reset for permissions (will set permission to RW all users)

The file will quietly copy to Evernote without need for your intervention.

You don't need to worry about setting the full access rights to everybody. The file is being copied (not moved) by Evernote and thus inherits proper permissions. You can check it under....

"/Users/__YOUR_USER_NAME__/Library/Application Support/Evernote/external edits/__UNIQUE_FOLDER_NAME__/"

Here is the edited script (note - I am not a programmer and I have only a limited knowledge, so the way I edited the script is not very elegant way)


----------------------------

(*
http://veritrope.com
Folder Action -- Evernote Exporter
Version 1.0
June 7, 2010
Project Status, Latest Updates, and Comments Collected at:
http://veritrope.com/tips/evernote-desktop-folder
*)
property theNum : "0"
property EVnotebook : ""
property EVTag : ""
property thename : ""
property theNotes : ""
property theBody : ""
property theURL : ""
on adding folder items to this_folder after receiving added_items

(*RESET LOCK *)

tell application "Finder"
set locked of every file of folder this_folder to false
end tell

(*RESENT PERMISSIONS *)

tell application "Finder"
set fold_name to the name of this_folder
try
repeat with i from 1 to number of items in added_items
set new_item to item i of added_items
set the item_path to the quoted form of the POSIX path of new_item
do shell script ("/bin/chmod -R ugo+wr " & item_path)
end repeat
end try
end tell


(*MAIN PROGRAM *)

tell application "Evernote"
--set successCount to 0
set EVTag to ""
set EVnotebook to "NAME_OF_YOUR_DEFAULT_NOTEBOOK"
repeat with i from 1 to number of items in added_items
set new_item to item i of added_items
create note from file new_item notebook EVnotebook tags EVTag
(*DELETE THE TEMP FILE/FOLDER *)
end repeat
end tell

delay 5

tell application "Finder" to delete added_items
end adding folder items to


------------------------------

Link to comment

I got this to work with my text files (notes exported by Mark/Space Notebook BUT they all have identical subject lines:

"Auto Import Macintosh HD:Users:rnwarbur:Desktop:Evernote Auto-Import:.DS_Store" - which makes them pretty useless

What they SHOULD have as the note title is just the first line of text in the text file.

I see this line in your script that causes the title creation:

create note from file this_item title "Auto Import " & this_item

Can't you change that line so that instead it picks up the first line of text?

Link to comment

Dear Justin,

 

I have been using your script very successfully. I have an @Evernote folder which now automatically adds content to Evernote. Great.

 

I have set up a folder for a more specific purpose. It is called "@PHOTOS Evernote" and I would like to upload photos to Evernote using this folder.

How can i amend the script to ensure that the folder contents go direct to a folder called "---PHOTOS" in Evernote and do not have the @Evernote tag.

 

Thanks

Link to comment

i did this. created a folder "Evernote Auto-Import" in my Documents folder.

Enabled folder actions. Created the script that is also stored in Documents/scripts folder (stores as scpt).

And then did the attach script as advised. Attached is an image to show what I did.

But nothing happens after I put files in this folder. No fail, no success! What am I doing wrong?

Image attachment below.

20081113-cnhjpj1qfmtixqwqe4i5g36fsj.jpg

Link to comment

Thanks for the info.

While not quite as useful as I thought it might be, still a nice script.

There are times I get text files that I wish to upload to Evernote. I thought I would just be able to drag copies of these files into this folder and the action would upload it nice and neat rather than opening the file, copying, pasting to Evernote and closing the file.

Any reason this type of functionality couldn't be supported?

Thanks,

Steve

Link to comment

The filenames varied from "test.sh" to "test.java". I didn't actually try a file with a .txt extension, but rather files that were of type plain text. Is the ability for Evernote to import a note based on the file extension and not the datatype?

Link to comment

Hmmm. Yeah. Using the 'mdls' command line tool I can see that .java and .sh files both contain the metadata necessary for Evernote to decide that it can import the file:

mdls on a .java file:

kMDItemContentType             = "com.sun.java-source"
kMDItemContentTypeTree = (
"com.sun.java-source",
"public.source-code",
"public.plain-text",
"public.text",
"public.data",
"public.item",
"public.content"
)

mdls on a .sh file:


kMDItemContentType = "public.shell-script"
kMDItemContentTypeTree = (
"public.shell-script",
"public.script",
"public.source-code",
"public.plain-text",
"public.text",
"public.data",
"public.item",
"public.content"
)

I'll file a bug to add support for this metadata.

Link to comment

This is great, exactly what I was looking for.

One thing - is there a way of creating the note so that it has a title of just the filename? At the moment, I'm getting a really long title along the lines of:

Auto Import Macintosh HD:Users:xxx:Documents:Evernote:filename.pdf

I can see where in the script to deal with the 'Auto Import' part but how do I just get the filename instead of the whole path?

Thanks in advance.

Link to comment

ohh ok that is great. For a second I thought that there was no txt support.

I have one more question. I have alot of files(over 700) that are text files but they have different extension which I use another app to create. Is there a way to force EN to recognize that format as plain text? They are plain text files, just holding adifferent extension. I can do one time renaming but I am constantly updating those files and adding new ones and I would like to implement those files into EN dynamically.

Link to comment

Right now, we only use the extension on the file to determine its type. This means that files with a random other extension won't be processed automatically unless you rename them. Like Geech says, we plan to try to expand this behavior a bit in the future, for files that identify themselves as plain text.

Link to comment

I think your folder isn't working because you have the right box filled in. From what I understand, if you put something in that "on" box, the folder action "auto-import", in this case, will only activate once that other script is called.

Simply get rid of that other script, and you should be good.

Also, everyone, keep in mind that this only auto-imports on Evernote's startup (from what I can tell). So if you send something to that folder while Evernote is open, nothing will happen.

Link to comment

Simply get rid of that other script, and you should be good.

hi. i am afraid i did not understand what you mean when you say get rid of that. i tried un-checking the script "on" option first. that did not work. then i unchecked the folder and checked the script that did not work either. :)

is it possible to restate the steps with more granularity in the "attach script" step?

thanks!

Link to comment

Yeah...sorry about that. As I was writing it, I thought "what the heck am I saying?"

Anyway, good news. I will restate what I said, and I also finished version 2.0 of my HP 6200 scanner workflow.

To restate my statement:

Why do you have that script in the right box? I have no such thing. Highlight the "send to evernote.scpt" and hit the " - " below that box.

That is all I was saying.

As for version 2.0 of my workflow, HERE it is. Keep in mind each time you login you will need to be sure Folder Actions are enabled. I couldn't figure out how to do that with this workflow (yet). Once you enable it when you login, it will work fine, though.

I hope this helps!

Link to comment
To restate my statement:

Why do you have that script in the right box? I have no such thing. Highlight the "send to evernote.scpt" and hit the " - " below that box.

I downloaded the workflow. The workflow requires folder options to be enabled right?

Now to enable that I followed the steps posted by the OP. When I follow those steps is when this script gets attached to the folder in question.

In summary, here is what I did.

Created a new folder in Documents folder. Enabled folder options on that folder. Attach script which I saved in Library/scripts/folder options script.

Then I copy a pdf file in that folder and wait for the pdf to be magically imported into evernote.

but no luck :). scanning directly into evernote does not even come into the picture yet...

Link to comment

Hmmf.

Weird.

Okay, here is what I did step by step. Nothing left out. Nothing simplified.

1. Copy code from this thread.

2. Open Script Editor.

3. Paste code.

4. Compile code.

5. File>Save As

6. Save script in Macintosh HD>Library>Scripts as "Evernote Auto-Import"

7. Make folder in Home>Documents called "Evernote Auto-Import"

8. Right-click this folder

9. More>Attach a Folder Action

10. Select the "Evernote Auto-Import" script.

11. Right-click the folder again.

12. More>Configure Folder Actions.

13. Close that window that pops up.

14. It should work now.

THERE MAY BE SOMETHING MISSING BETWEEN 10 AND 11, I AM NOT SURE.

Did you do anything differently?

P.S.- I see where that script in the right-box comes from. I only get it when I select the script in the left box. Also, mine has the same title as the script on the left.

Link to comment

As for my problem with needing to re-enable the folder actions with each login (so every time I login I have to re-enable them), I went on to Apple Discussions and seem to have found a solution.

I went to myUsername/Library/Launch and removed these files (trash them)

com.apple.FolderActions.enabled.plist

com.apple.FolderActions.folders.plist

And then logout. Then log back in-add the folder actions (if you need to) again, and then you should be good. I did a quick log-in log-out test to be sure, and it seems to have worked.

Link to comment

I have finished version 3 of my Automator script. It no longer quits Evernote (due to some new information...something was wrong with my system so I thought this was necessary). It also no longer attempts to open the Evernote Auto-Import folder in Finder (not necessary).

It is available HERE.

Link to comment

I am a relatively new Mac user and have not been able to quite fully make the adjustment from PC. When I try to follow your directions I am unable to find the "Enable Folder Actions" option. When I right-click on the desktop folder the options I see are included in the attached screen shot (I couldn't figure out how to paste it into my post.

Any assistance would be greatly appreciated.

Thanks,

Michael

post-19213-131906064729_thumb.png

Link to comment

Archived

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

×
×
  • Create New...