The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Folder action for automatically adding new files to OmniFocus Thread Tools Search this Thread Display Modes
A user emailed earlier in the week wondering if there was a way to automatically add bills that he was scanning as PDFs to OmniFocus as actions. He knew that he could have his scanning software place the PDFs in a particular folder, but wasn't sure how to get them into OmniFocus from there without too many clicks.

The answer I came up with is the attached Folder action script. It takes any files that are added to the folder and attaches them to individual actions in the quick entry window.

To use, extract the .scpt file from the .zip and place it in /Library/Scripts/Folder Action Scripts/. You can add the action to any folder by control-clicking that folder in the finder and choosing Services >Folder Actions Setup...

I am by no means an AppleScript expert so there may be some situations where the script fails, but in my testing here it works well. As always, your feedback is welcome
Attached Files
File Type: zip Add files as OmniFocus actions.scpt.zip (2.7 KB, 515 views)
 
Quote:
Originally Posted by dave_m View Post
To use, extract the .scpt file from the .zip and place it in /Library/Scripts/Folder Action Scripts/.
Looks good.

I would probably tend to install it in
~/Library/Scripts/Folder Action Scripts
(where ~ is the user's home folder)
rather than
/Library/Scripts/Folder Action Scripts
(under the root, affecting all users)
 
I'm assuming it leaves the attached file in the folder with the folder action attached? Is that right?
 
Quote:
Originally Posted by kingsinger View Post
I'm assuming it leaves the attached file in the folder with the folder action attached? Is that right?
That's right, it doesn't do anything to the file, just opens the quick entry window and makes an action with the file embedded.
 
Quote:
Originally Posted by whpalmer4 View Post
That's right, it doesn't do anything to the file, just opens the quick entry window and makes an action with the file embedded.
What happens if you move the file later? Does OF put a copy of the file in its own directory somewhere that isn't affected by moving the file in the original folder? Or does the link adjust to the new location?
 
Note that I said "embedded" :-) It puts a copy of the file in the database, and you'll sync it all around, if you are syncing. If it is a file you are going to change, you need to proceed with caution or you will be burned sooner or later by not getting your changes back into the database copy. I don't recommend embedding files that you plan to edit unless you really understand how it all works. Safer to put it somewhere like MobileMe or Dropbox where you can edit it directly, and just have a link to the file (or even just the name). On the other hand, if it is a file you are only going to reference, not change, and the size isn't too large, you shouldn't have any trouble.

If you do embed a large file, note that you won't be truly rid of it until after all of your syncing devices have synced the change where you delete it and had an opportunity to compact the database (normally at least an hour later).

If you've linked a file instead of embedding it, if the file is no longer present at the same location, attempts to open it will get you a file chooser dialog along with a warning that the file cannot be located at the old path. If you navigate to the new location, the link in the db gets updated, or you can cancel and deal with it at some other time. If this behavior makes you think "hmm, maybe they just store the path to the file at the time I attached it" you would be 100% correct. A nice side effect of doing it this way is that if you've stored the file in a place that has the same path on any system you use (MobileMe, for example), you don't actually have to cart the payload around.
 
Hi

Thanks for the script. Does anyone have suggestions for an addition to the script that would close the quick entry window rather than leaving it open?

I've taken a look but so far it's beyond me.

Kevin
 
Here's an updated version of the script that allows customization of the behavior. The two properties at the top of the file control whether files are embedded or linked, and whether actions are added to the Quick Entry window or filed directly in the Inbox without user intervention.

If you want different behavior in a bunch of different directories, it might be worth making a couple of copies of the script, setting the properties, and saving with descriptive names.
Attached Files
File Type: zip Add files as OmniFocus actions.scpt.zip (5.1 KB, 445 views)
 
Being an absolute AppleScript novice, to say the least. Would there be a way to take this Folder action script and modify it to add a default Project and context to the action as well?

This would simply make my year.

Here on David Sparks site he describes how to make an action via applescript with a default project and context:

-- Lovingly crafted by David Sparks, The Omni Group, and Ben Waldie -- macsparky.com

set theDate to current date
set theTask to "Pay Life Insurance"
set theNote to "Lovingly Scanned by your Mac on " & (theDate as string)

tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "Tech"
set theProject to first flattened project where its name = "Finance"
tell theProject to make new task with properties {name:theTask, note:theNote, context:theContext}
end tell
end tell

I am trying to accomplish some rather in depth Hazel, Paperless, automatic OCRing mojo and I thought I could simply look at the applescripts and combine them myself, but... Way beyond me. I know someone with some AppleScript chops can do it, probably in an instant.

Thanks in advance.

Last edited by m_kuhn; 2012-11-24 at 03:32 PM.. Reason: Forgot to Subscribe
 
Quote:
Originally Posted by m_kuhn View Post
Being an absolute AppleScript novice, to say the least. Would there be a way to take this Folder action script and modify it to add a default Project and context to the action as well?

This would simply make my year.
Attached is a modification of Bill Palmer's script which allows you to specify the project and context when adding the task. (You can't specify a project when using Quick Entry due to a limitation in OmniFocus 1, and the items are always left in the Inbox since I minimally modified the existing script.)

Hopefully you can adapt this to your Hazel workflow without too much difficulty.

óJim
Attached Files
File Type: zip Add files as OmniFocus actions.scpt.zip (18.4 KB, 291 views)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export each object automatically as separate PNG files PipSqueak OmniGraffle General 1 2013-02-12 02:38 PM
Default to next action when adding a new action? ethant OmniFocus 1 for Mac 0 2010-10-06 01:55 PM
Where is my database saved? [A: the OmniFocus folder inside App Support folder] Michael Blake OmniFocus 1 for Mac 2 2009-08-10 02:08 PM
Action Groups Don't Get Marked as Done Automatically minato2 OmniFocus for iPhone 15 2008-11-25 12:39 PM
5.0 b Why are layers locked down automatically when editing 4.x files? dude OmniGraffle General 0 2008-01-23 06:29 PM


All times are GMT -8. The time now is 04:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.