AppleScript to create task in OmniFocus Inbox with Hazel

Screen Shot of Hazel

tell application “Finder” to set file_name to (name of theFile)

tell application “OmniFocus”
set task_title to "Pay " & file_name
tell default document
set newTask to make new inbox task with properties {name:task_title}
tell the note of newTask
make new file attachment with properties {file name:theFile, embedded:false}
end tell
end tell
end tell

1 Like

Hi this is my favorite script, but could you tell me please how to remove extension of file from task title? I’m a beginner in AppleScript and I’ve tried a lot but I could not do it (:

Change the line

set task_title to "Pay " & file_name

to:

set task_title to "Pay " & (text 1 thru ((offset of "." in file_name) - 1) of file_name)

Note: This will truncate the filename after the first period/dot, so if there’s one in the filename other than the actual extension separator, it might not give the result you wanted.

1 Like

hi guys, pls find below the same apple script, which somehow does not seem to work anymore. since i am completely illiterate on this, could someone pls point me to what needs to be done to make it work again? i am running omnifocus pro 2.11.1 (v113.24) on mac os high sierra, 10.13.1. thank you so much for your help! best, nick


tell application “Finder” to set file_name to (name of theFile)

tell application “OmniFocus”
set task_title to "review - " & file_name
tell default document
set NewTask to make new inbox task with properties {name:task_title}
tell the note of NewTask
make new file attachment with properties {file name:theFile, embedded:true}
end tell
end tell
end tell