The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Send selected Finder document to OF inbox as task (http://forums.omnigroup.com/showthread.php?t=7290)

Marek Kowalczyk 2008-02-24 11:45 PM

Send selected Finder document to OF inbox as task
 
Hi,

I often find myself needing to read/review a document that's sitting somewhere on my disk.

Rather than putting all the documents needing a review to a "To be reviewed" folder, I decided to try put toghether a quick and dirty script to help me with that, inspired by Curt Cliftons [URL="http://www.rose-hulman.edu/~clifton/software.html#SendURL-OF"]Send URL to OF[/URL].

The script gets the name of the selected Finder documents and creates an OF task in the inbox called "Read XXX:YYY:ZZZ.pdf".

Ideally:[LIST][*]the task name should just be the file name, without the full path[*]the task note should contain the alias to the file[*]the script should check if one document is selected, and not a folder[/LIST]but that's beyond my non-existent knowledge of Apple Script.

Maybe you'd like to add this functionality.

[CODE]-- Written by Marek Kowalczyk, inspired by Curt Clifton

property actionPrefix : "Read "

tell application "Finder"
set theName to the selection
end tell

tell front document of application "OmniFocus"
make new inbox task with properties {name:(actionPrefix & theName)}
end tell[/CODE]

RobTrew 2008-02-25 11:54 AM

This slight extension allows for multiple selections in the Finder, ignores folders, and creates a URL link to the file in the note of the Omnifocus task.

The first draft did, however, reveal a minor bug in Omnifocus: the links do not immediately appear blue and clickable, only becoming so after the cursor has been placed on them, and the note has been opened and closed a few times.

The bug is probably worth reporting.

A solution is to add an alias after the URL, as below.

[CODE]tell application "Finder"
set lstSelected to selection
if (count of lstSelected) > 0 then
tell application "OmniFocus"
activate
set oDoc to front document
end tell

set strPath to POSIX path of (folder of front window as text)

repeat with oSeln in lstSelected
if class of oSeln is document file then
tell oSeln
set strName to name
set strURL to URL
end tell
using terms from application "OmniFocus"
tell oDoc
set oTask to (make new inbox task with properties {name:"Read " & strName, note:strURL})
tell note of oTask
make new file attachment with properties {file name:strPath & strName}
end tell
end tell
end using terms from
end if
end repeat

tell application "OmniFocus" to activate
end if
end tell
[/CODE]


All times are GMT -8. The time now is 08:58 AM.

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