Move Done's To End of Project Moves done tasks within every project in frontmost document to the end of the tasks' project. Please Note: 1. Does NOT preserve the order of the done tasks. 2. Does NOTHING to orphan tasks (i.e., not contained in a project).
tell application "TaskPaper"
tell front document
repeat with theProject in projects
tell theProject
set taskCount to count tasks
if taskCount > 1 then
set theTask to last task
set sorted to true
repeat taskCount times
set thePreviousTask to previous sibling of theTask
if not sorted then
if exists tag named "done" of theTask then
move theTask to end of tasks
end if
else
if sorted and not (exists tag named "done" of theTask) then
set sorted to false
end if
end if --not sorted
set theTask to thePreviousTask
end repeat --taskCount times
end if --if taskCount > 1
end tell --theProject
end repeat --with theProject in projects
end tell --front document
end tell --application "TaskPaper"