The Omni Group Forums

The Omni Group Forums (
-   OmniFocus Extras (
-   -   Applescript to move "maybe someday" projects to separate .ofocus file (

fudster 2010-02-11 10:24 AM

Applescript to move "maybe someday" projects to separate .ofocus file
Anyone have any success in emulating the "copy" (or cut) and "paste" menu commands in OmniFocus, using Applescript?

Here's the background of what I'm trying to do...

I have a non-default .ofocus document (~/Documents/Projects/maybe someday.ofocus), where I keep my maybe someday projects. Yes, I know I could just keep them in my default omnifocus document, put them on hold, and hide them, but I use on-hold projects a little differently - I use them to maintain loose dependencies between projects, i.e. when a project blocks another (see [URL=""]this thread[/URL] for more on how I do this). All projects in my default/main ofocus document represent some concrete commitment I've made for completion, even if they're on hold. I can be pretty fanciful with my maybe-someday projects, so there are a lot of them, and having them in my default document bogs down my review cycle (not to mention my MobileMe/iPhone sync). I recall that DA has a large number of maybe-someday projects, in comparison with those he considers active. Anyway...

I want to create a script to help with this part of my workflow. When I create or identify a project to which I have no concrete commitment to ever complete, I want to move the project to my "maybe someday.ofocus" document. The project may already reside in its appropriate sidebar folder, if I've clarified its meaning to me and its place (area of focus) in my life overall - so I want to preserve the parent hierarchy - I actually want to maintain (roughly) the same folder structure in both documents. Eventually I also want to script to move projects the other way - i.e., when a maybe-someday project gets some traction and I make a commitment to getting it done.

What I want to do is quite similar to what jharrison did in his cool [URL=""]Project Folder script[/URL], except, instead of opening (or lazily creating) folders on the filesystem, I want to lazily create the parent folders in the sidebar of the "maybe someday.ofocus" document, and put the moved project in the same spot there.

"Why not just drag them in?" If you've ever tried dragging anything from one ofocus document to another, you've probably noticed the weird thing that happens - all parent folders for the dragged item in the one document are created in the other, but they're created flat - as siblings at the top level - and the project also winds up at the top level. Obviously a bug, but I'd rather do this via a script anyway - I need to be able to sling maybe-someday projects out of the way quickly to keep the (daily) review as slick and quick as possible. Mousing and dragging are too slow, so I want to assign a keystroke (i.e. using FastScripts).

I've gotten started and have made some progress. I'm able to lazily create the parent folder structure in the "maybe someday.ofocus" document. However, when it comes to actually creating the project there, I'm at a crossroads...

[LIST][*]I'd hoped to be able to use the "duplicate" command, but it doesn't work across ofocus documents (an error dialog appears specifically saying that it isn't supported).[/LIST]
[LIST][*]When I select a [set of] project[s] in OF, and press Cmd-C, then go to the maybesomeday.ofocus document and press Cmd-V, it does exactly what I want - the whole project[s], including notes, child tasks, and groups, are pasted. The trick is doing this programmatically using Applescript. I've messed around with using the pbcopy command and "set the clipboard". It's pretty fussy about object types, and I get unhelpful error messages like:[/LIST][INDENT][LIST][*] "Can't make some data into the expected type" (on paste operation)[*] "Canít make project id "hWcay7__OP4" of document id "kWSTxCKhYfE" into type project."[*] "Can't make {specifier:project id "hWcay7__OP4" of document id "kWSTxCKhYfE"} into type specifier."[/LIST][/INDENT][INDENT]I'm not done exploring this yet, but I've been having trouble finding examples of using the clipboard for anything but text. I've thought of using AppleScript to activate the document windows in order and invoke the keystrokes to do the copy/paste - I may try this, but it feels a little dangerous.

[/INDENT][LIST][*]could reconstruct the graph of data for the project using AppleScript - I'm willing to slug it out and write the code recurses the original project and builds the copy, and its notes, child tasks, groups, etc, from the top down. However, it occurs to me that if I could just invoke the existing Copy/Cut and Paste, it would be much easier.[/LIST]Any thoughts or hints on how to do this in Applescript would be most welcome. Cheers...

fudster 2010-02-11 10:44 AM

fyi the genesis for me of the way I'm using the .ofocus file is [URL=""]here[/URL].

All times are GMT -8. The time now is 01:46 AM.

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