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

Applescript for Attaching file to action Thread Tools Search this Thread Display Modes
This is for the Applescript Guru's:

Let me start that I have checked the forums and could not find a working solution for my question:

What I would like to accomplish is to scan a bill with my Fujitsu ScanSnap 1300 and make this an attachement in a new task in my Inbox. Preferably I should see the task opened so I can edit dates, contexts and such.

The idea is to end up with a (bill paying) tickler stored in Omnifocus that will come up on my rader on the date the bill should be paid. I can then open the attachement for the payment details. The same would hold true for for example a seminar invitation that I do not wish to decide upon today but on a later date. I would scan the invitation and transform that into a task.

I can enter applescript in Hazel. To get the file being handled in Hazel I have been able to manage. The script should be able to run in Hazel and open the Entrybox of Omnifocus for further edit of the action text, context, etc. The scanned file should be able to be seen as an attachement in the note section of the action.

As I am running a paperless office (sort of) I do not wish a link to the file on my Mac but the attachement directly into the action in Omnifocus.

All hard copies will be shredded (or filed if for my business). The scanned files on the iMac's disk will be deleted or moved to Evernote for archive.

Please, is there anybody out there that can help me out?
Nobody can help me with this?

Jos van der Voort
Hey, my ScanSnap just arrived a day or two ago :-)
When i scan a file to my desktop and ctrl click on that file, I get the Send to Omnifocus command and that does EXACTLY what I want the script to do.

Now who can help me realize this in Hazel?
Here is the solution for this problem (provided to me by the kind folks at OF who wrote the applescript specifically for me - Thanks Jameson!):

The attached script will run automatically when you add new files to a folder- the script should open the Quick Entry window in OmniFocus with the scanned image attached in the Notes field. Note: it does not need Hazel but you can use Hazel to clean up the folder automatically, which will make the workflow "set and forget". Here's what you'll want to do:

- Download the attached script

- Unzip it

- Drop the script into this folder:

Macintosh HD>Library>Scripts>Folder Action Scripts

- Create a folder for your scanned items

- Right-click on this folder, and select Services>Folder Actions Setup

- Select the "Add files as OmniFocus actions" script

- Click Attach

Now, any time you scan something and save it in this folder, the script will run to send the image to OmniFocus. Hope this helps!

Attached Files
File Type: zip (2.7 KB, 378 views)
Unfortunately this script doesnít work with multi-page documents. As soon as the ScanSnap writes the first page of the document, this triggers the Folder Action and loads that first page into OmniFocus, even as the second page is being pulled through your scanner.

The solution Iíve come up with is to have the ScanSnap scan to one folder, and then have Hazel (which can be configured to wait 1 minute before processing new files) move it to the folder with the Folder Action attached to it. The minute delay is pretty annoying, but it works.

Hazel can also be configured to trash the scanned files after a few minutes so they donít clutter up your hard disk.

Last edited by Kevin Yank; 2011-03-16 at 03:56 AM..
Hi Kevin,

I have just checked: a multipage document works fine with my setup. I cannot duplicate your problem. Maybe the ScanSnap settings?

I can reproduce it reliably by setting ScanSnap Manager to create a PDF file in a folder with the Folder Action attached. Scan a page, then wait a moment while ScanSnap Manager prompts you to insert another page or click Finish Scanning. The Folder Action is triggered at that point, even though you may have more pages to scan.

I’ve found a perfect solution, though: Use Automator to create an Application containing a single Run AppleScript step with the following code:

on run {input, parameters}
if (class of input) is not equal to list then set input to {input}
repeat with i in input
tell application "Finder" to set file_name to (name of i)
tell application "OmniFocus"
tell quick entry
set NewTask to make new inbox task with properties {name:file_name}
tell the note of NewTask
make new file attachment with properties {file name:i, embedded:true}
end tell
end tell
end tell
end repeat
end try
return input
end run

Save the application in your Applications folder, then set up your profile in ScanSnap Manager to open the scanned document using your new application.
I do not have the scansnap set up to prompt page by page. That may be the difference.

I will try the Applescript. Does it run faster than the folder action script?
You have ScanSnap set to write one PDF per page. If you go into the settings, select the "File option" tab, and then click the "Option ..." button you can tell ScanSnap to write multipage PDFs. Each batch scanned in will be assembled as one document in one PDF. That would solve your folder action problem.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Siri attaching notes to every action mavric OmniFocus for iPhone 3 2012-07-27 08:35 AM
Is there an Applescript process for attaching files in Outliner jes AppleScripting Omni Apps 1 2010-05-10 02:43 PM
New file via Applescript: do I have this right? Eponymous OmniOutliner 3 for Mac 2 2009-01-31 10:09 AM
Applescript example: exporting to a text file RobTrew OmniFocus Extras 6 2007-09-11 08:27 PM
Using Applescript to Attach File BillB OmniOutliner 3 for Mac 1 2007-04-16 03:55 PM

All times are GMT -8. The time now is 09:07 AM.

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