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

 
Geek Tool and OF export Thread Tools Search this Thread Display Modes
That script has some problems if you've got characters that are special to the Unix shell in any of your actions. I would suggest replacing these two lines:

Code:
	set strCmd to ("echo " & quote & strList & quote & " > " & POSIX path of (path to desktop) as string) & "NextActions.txt"
	do shell script strCmd
with

Code:
	set fRef to (open for access ((POSIX path of (path to desktop) as string) & "NextActions.txt") with write permission)
	write strList to fRef
	close access fRef
Then the world will be safer for actions that have characters like '(', ')', ':', etc. in them :)
 
phatuser: You need to create another Geeklet which reads the text file.
Something like:
Code:
cat that/text/file.txt
Should work.
 
I notice that the ListNext script (for writing a list of next actions to a file) has been downloaded quite a lot over the years.

As of OmniFocus ver. 1.8, it can be written much more simply, without recursion. Adopting WhPalmer4's improvement to allow for special characters when writing the file, the whole script could now be abbreviated to something like:

Code:
on run
	-- GET THE DUE DATES, NAMES, AND CONTAINING PROJECTS OF ALL NEXT ACTIONS
	tell application id "com.omnigroup.omnifocus"
		tell default document
			set refTasks to a reference to (flattened tasks where next is true)
			set {lstDue, lstTask, lstProject} to {due date, name, name of its containing project} of refTasks
		end tell
	end tell
	
	-- BUILD A LINE OF TEXT FOR EACH ACTION
	set str to "Next" & return
	repeat with i from 1 to length of lstTask
		set {dteDue, strName, strProject} to {item i of lstDue, item i of lstTask, item i of lstProject}
		set strDue to ""
		if dteDue is not missing value then set strDue to short date string of dteDue
		
		set str to str & tab & strDue & tab & strName
		if strProject ≠ strName then set str to str & " [" & strProject & "]"
		set str to str & return
	end repeat
	
	set fRef to (open for access ((POSIX path of (path to desktop) as string) & "NextActions.txt") with write permission)
	write str to fRef
	close access fRef
end run

Last edited by RobTrew; 2011-01-13 at 03:24 AM..
 
For a GeekTool list, you could run this even simpler version (which just returns a string value, rather than writing out a file).

If the script is called ListNext03.scpt you could install it in your OmniFocus script directory, and run it from GeekTool with a command like:

Code:
osascript ~/Library/Scripts/Applications/Omnifocus/ListNext03.scpt | tr '\r' '\n'
(piping it through tr to convert applescript's return characters to shell-compatible newline characters).

--

Last edited by RobTrew; 2011-07-05 at 08:46 AM..
 
These scripts are wonderful! Do you know if there is a way to list tasks only in a specific Perspective? Being able to export a list of actions in a particular Perspective is the only thing missing here.

Thank you for making these available!
 
Quote:
Originally Posted by BrianM View Post
Do you know if there is a way to list tasks only in a specific Perspective? Being able to export a list of actions in a particular Perspective is the only thing missing here.
The OmniFocus applescript library doesn't directly offer a list of tasks in exchange for a perspective name, but you can certainly define custom lists by editing the clause in the script above which reads:
flattened tasks where next is true
and you can use a post on this forum (which lists applescript clauses for the OF various filters) as a cookbook from which to assemble your own recipes. For example:
flattened tasks where (flagged is true) and (estimated minutes <= 30)
or
flattened projects where ((status is active) or (status is on hold) and ((effectively hidden of its folder is false) or (its folder is missing value)))
(You can use the Where in OF script to test these recipes before using them in a custom applescript).

--

Last edited by RobTrew; 2012-07-17 at 07:48 AM..
 
Thanks so much for your quick reply. I'm playing around a little and I think I can get it to work for what I need, but I'm getting an error when running some of the scripts using osascript:

osascript: couldn't save changes to script /Users/brian/Library/Scripts/Applications/Omnifocus/ListNextFile03.scpt: error 4294965546.

I haven't been able to figure out what is causing this. Any ideas?
 
This version allows for a variety of custom task lists, and can be used either to create text files, or for displaying lists in Geektool windows.

If you install it in your OmniFocus script folder as:
~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt
you can then run it from the Terminal (or in Geektool) with arguments specifying the query and the list header (optionally redirecting the output into a text file).

(Note that the query and header should be enclosed in single quotes)
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt 'flagged is true' 'Flagged' > FlaggedTasks.txt
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt 'next is true' 'Next actions' > NextActions.txt
For use with Geektool, there is no need to redirect to a text file. Just give the query and the header
osascript ~/Library/Scripts/Applications/Omnifocus/OFTaskList.scpt '((due date ≤ soon) or (flagged is true))' 'Soon and Flagged'
If no arguments are supplied, the script still defaults to outputting a Next Actions list.

For details of the queries corresponding to OF filter settings, see the FAQ on this forum. The terms now and soon can both be used in queries involving dates. Soon will be interpreted in accordance with your setting under:
OF > Preferences > Data > Due "Soon" is in the next N days
--

Last edited by RobTrew; 2011-07-05 at 08:46 AM..
 
Quote:
Originally Posted by BrianM View Post
osascript: couldn't save changes to script /Users/brian/Library/Scripts/Applications/Omnifocus/ListNextFile03.scpt: error 4294965546.

I haven't been able to figure out what is causing this. Any ideas?
Sounds like you may also have the script open in your applescript editor. Closing it before using osascript should fix it.

See, however, the new script, above, which allows you to to give custom queries as arguments on the command line. This may save you customizing your own scripts.
 
You were right that I needed to close Script Editor; now it works fine.

And this new script is PERFECT for what I need - I can just recreate my perspectives using the correct fields and it works just like I want. THANK YOU!

Now I guess I need to actually DO some of the items on my list instead of messing around with scripts. :-)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool tip display Ray OmniWeb General 0 2008-12-30 07:58 AM
using the 'Search' tool peterlemer OmniFocus 1 for Mac 2 2008-08-20 07:33 AM
Is OmniPlan the tool I need? sriggins OmniPlan General 2 2007-10-08 04:29 PM
Hand Tool donovan OmniWeb Feature Requests 0 2007-06-03 03:58 PM
Additions to tool bar Jon Saperia OmniPlan General 2 2006-10-02 11:33 AM


All times are GMT -8. The time now is 12:51 PM.


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