Updating the MacSparky DropBox txt file to inbox task script

Hi,
I don’t know Applescript very well - but I’ve used this script in Hazel fine with v1.

set p to POSIX path of “/Users//Dropbox/text_files/of.txt”
set input_file to POSIX path of p
set l to paragraphs of (do shell script "grep . " & input_file)
do shell script “>” & input_file

tell application “OmniFocus” to tell document 1
repeat with v in l
make new inbox task with properties {name:v}
end repeat
end tell

If I run this in the Applescript editor, the make new inbox task line fails with:

error “OmniFocus got an error: Can’t get document 1. Invalid index.” number -1719 from document 1

I still have OF v1 on this machine (I just haven’t gotten around to deleting it yet). Will this cause problems, or is there something else I need to update on that line?

Thanks in hope!

I guess it’s related to having the two versions. Check on Activity Monitor (or your Applications folder) how are your apps identified and change the line below accordingly on your script.

tell application "OmniFocus" to tell document 1

I did something similar recently, based on David’s script. This one sends anything from Hazel to OmniFocus. As inspiration: run this script from Hazel when there was an error, so you have a task to do in OmniFocus.

1 Like

While we’re on the subject, it’s probably slightly better form to use default document instead of document 1 to ensure your data will go to the main database, rather than an archive or backup that happens to be the current document open.

1 Like

Hi
I did something similar but still getting the same error. Any help. I tried both the options but no luck.

I have a To Do folder in drop box and I want to create a task from that folder.

here is what I get the error.

2016-02-05 19:37:29.242 hazelworker[8970] Done processing folder Dropbox
2016-02-05 19:38:02.701 hazelworker[8975] ###main load address: 0x109c16000
2016-02-05 19:38:02.703 hazelworker[8975] ###Noodle load address: 0x109d2b000
2016-02-05 19:38:02.703 hazelworker[8975] ###CK load address: 0x109cf0000
2016-02-05 19:38:03.958 hazelworker[8975] Processing folder Dropbox
2016-02-05 19:38:06.328 hazelworker[8975] todo: Rule To Do Omnifocus matched.
2016-02-05 19:38:10.357 hazelworker[8975] [Error] AppleScript failed: Error executing AppleScript on file /Users/Ajhawar/Dropbox/todo.
2016-02-05 19:38:10.357 hazelworker[8975] OSAScript error: {
NSLocalizedDescription = “OmniFocus got an error: Can\U2019t get flattened project 1 of document 1 whose name = “Work”. Invalid index.”;
NSLocalizedFailureReason = “Can\U2019t get flattened project 1 of document 1 whose name = “Work”. Invalid index.”;
OSAScriptErrorAppAddressKey = “<NSAppleEventDescriptor: [0x0,da0da “OmniFocus”]>”;
OSAScriptErrorAppNameKey = OmniFocus;
OSAScriptErrorBriefMessageKey = “Can\U2019t get flattened project 1 of document 1 whose name = “Work”. Invalid index.”;
OSAScriptErrorMessageKey = “OmniFocus got an error: Can\U2019t get flattened project 1 of document 1 whose name = “Work”. Invalid index.”;
OSAScriptErrorNumberKey = “-1719”;
OSAScriptErrorRangeKey = “NSRange: {0, 0}”;
}
2016-02-05 19:38:10.477 hazelworker[8975] Done processing folder Dropbox