The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Applescript for Attaching file to action (http://forums.omnigroup.com/showthread.php?t=19939)

dg005978 2011-01-30 06:46 AM

Applescript for Attaching file to action
 
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?

dg005978 2011-02-11 05:37 AM

Nobody can help me with this?

Jos van der Voort

whpalmer4 2011-02-11 07:02 AM

Hey, my ScanSnap just arrived a day or two ago :-)

dg005978 2011-02-11 07:06 AM

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?

dg005978 2011-02-21 06:36 AM

1 Attachment(s)
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!

Enjoy!

Kevin Yank 2011-03-16 03:48 AM

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.

dg005978 2011-03-16 04:19 AM

Hi Kevin,

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

Jos

Kevin Yank 2011-03-16 04:32 AM

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}
try
repeat with i in input
tell application "Finder" to set file_name to (name of i)
tell application "OmniFocus"
tell quick entry
open
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
activate
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.

dg005978 2011-03-16 04:41 AM

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?

GrumpyDave 2011-03-16 07:50 PM

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.


All times are GMT -8. The time now is 10:01 PM.

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