More information and downloadable versions of these scripts.
Requires TaskPaper 2.2 or later. Updated 16 Jan 2009, 12:30 pm EST
These scripts are designed to integrate a TaskPaper document with folders in the file system that contain project-related files and notes. They allow a project folder or a project notes file to be opened quickly for a TaskPaper project that contains a selection or the cursor in its name or in one of its tasks or notes. If the folder or notes file don't exist, the scripts will create them, with an option to cancel, incrementally building a folder hierarchy that matches the project hierarchy in the TaskPaper document.
The first script opens or creates a folder with the same name as a TaskPaper project that contains the cursor or a selection, or the containing project of an entry (task or note) that contains the cursor or a selection. Subproject folders are created within their containing projects' or subprojects' folders. Folders are located by default in ~/Documents/Projects. This location can be changed by editing the first two non-comment lines of the script:
-- By default the script opens or creates folders in a "Projects" folder located in
-- the Documents folder. These names and locations can be changed by editing the two
-- lines below.
set projectsFolderName to "Projects" -- name for main projects folder
set projectsPath to (path to documents folder as text) -- path to main projects folder
global projectsFolderName, projectsPath
tell application "TaskPaper"
if the entry type of the selected entry is project type then
set proximalProject to the selected entry
else if (the containing project of the selected entry is missing value) then
display dialog "Project folders are not available for individual top level tasks without projects." buttons {"OK"}
return
else
set proximalProject to the containing project of the selected entry
end if
set theFolder to my getFolder(proximalProject)
tell application "Finder"
activate
open folder theFolder
end tell
end tell
on getFolder(theEntry) -- returns the path to the folder, creating the folder if necessary
using terms from application "TaskPaper"
if the containing project of theEntry is not missing value then
set fname to the name of theEntry
set containingProject to the containing project of theEntry
set containerPath to getFolder(containingProject)
tell application "Finder"
if not (folder (containerPath & fname & ":") exists) then
display dialog "Create new subproject folder in the " & (name of containingProject) & " folder called \"" & fname & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at containerPath with properties {name:fname}
end if
end tell
return containerPath & fname & ":"
else
set fname to the name of theEntry
tell application "Finder"
if not (folder (projectsPath & projectsFolderName & ":") exists) then
display dialog "Create new main projects folder at " & projectsPath & " called \"" & projectsFolderName & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at projectsPath with properties {name:projectsFolderName}
end if
if not (folder (projectsPath & projectsFolderName & ":" & fname & ":") exists) then
display dialog "Create new project folder in the " & projectsFolderName & " folder called \"" & fname & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at (projectsPath & projectsFolderName & ":") with properties {name:fname}
end if
end tell
return (projectsPath & projectsFolderName & ":" & fname & ":")
end if
end using terms from
end getFolder
The following script is very similar to the script above that opens or creates folders. It opens or creates an OmniOutliner Pro notes document in a folder with the same name as the containing project of a TaskPaper entry that contains the cursor or a selection. The notes document is named "• {projectName} notes.oo3" by default. The default location and naming of the notes file, and the program used to create and open it, can be changed by a few simple script edits:
-- By default the script opens or creates a notes file in project or subproject folders
-- in a "Projects" folder located in the Documents folder. The folder names and locations can
-- be changed by editing the two lines below. The script creates OmniOutliner Pro notes
-- documents by default. To use another file and editor type for notes, just edit
-- the name of the editor program in two places in the script and, if necessary,
-- edit the file name extension in the third line below.
set projectsFolderName to "Projects" -- name for main projects folder
set projectsPath to (path to documents folder as text) -- path to main projects folder
set fileExtension to ".oo3"
global projectsFolderName, projectsPath
tell application "TaskPaper"
if the entry type of the selected entry is project type then
set proximalProject to the selected entry
else if (the containing project of the selected entry is missing value) then
display dialog "Project folders are not available for individual top level tasks without projects." buttons {"OK"}
return
else
set proximalProject to the containing project of the selected entry
end if
set theFolder to my getFolder(proximalProject)
set projName to the name of proximalProject
set projNotesName to "• " & projName & " notes" & fileExtension
tell application "Finder"
if exists file (theFolder & projNotesName) then
tell application "OmniOutliner Professional" -- edit if you wish to change the editor program
activate
open alias (theFolder & projNotesName)
end tell
else
display dialog "No notes file found for project \"" & projName & ".\" Create new notes file \"• " & projName & " notes\" in the " & projName & " folder?" buttons {"Cancel", "OK"} default button 1
tell application "OmniOutliner Professional" -- edit if you wish to change the editor program
activate
set notesDoc to make new document with properties {name:projNotesName}
save notesDoc in (theFolder & projNotesName)
end tell
end if
end tell
end tell
on getFolder(theEntry) -- returns the path to the folder, creating the folder if necessary
using terms from application "TaskPaper"
if the containing project of theEntry is not missing value then
set fname to the name of theEntry
set containingProject to the containing project of theEntry
set containerPath to getFolder(containingProject)
tell application "Finder"
if not (folder (containerPath & fname & ":") exists) then
display dialog "Create new subproject folder in the " & (name of containingProject) & " folder called \"" & fname & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at containerPath with properties {name:fname}
end if
end tell
return containerPath & fname & ":"
else
set fname to the name of theEntry
tell application "Finder"
if not (folder (projectsPath & projectsFolderName & ":") exists) then
display dialog "Create new main projects folder at " & projectsPath & " called \"" & projectsFolderName & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at projectsPath with properties {name:projectsFolderName}
end if
if not (folder (projectsPath & projectsFolderName & ":" & fname & ":") exists) then
display dialog "Create new project folder in the " & projectsFolderName & " folder called \"" & fname & "?\"" buttons {"Cancel", "OK"} default button 1
make new folder at (projectsPath & projectsFolderName & ":") with properties {name:fname}
end if
end tell
return (projectsPath & projectsFolderName & ":" & fname & ":")
end if
end using terms from
end getFolder