ArchiveCompletedTasks


Outdated!!!

This information is for TaskPaper 2 which is old and outdated. TaskPaper 3 is the current version of TaskPaper. For TaskPaper 3 support please visit the support forums.


Original

After my completed tasks begin accumulate and I'm done patting myself on the back for having been so productive, I like to archive my completed tasks off to another file. This is a basic script to open an archive file, move the completed tasks to the archive file, save and close the archive file. To use this file, change the top three properties to match your configuration (file names and path to the archive).

property currentFile : "Todo.taskpaper"
property archiveFile : "Done.taskpaper"
property archiveFilePath : "/Users/yourname/Documents"

tell application "Finder"
    if exists (archiveFilePath & "/" & archiveFile) as POSIX file then
        tell application "TaskPaper"
            open archiveFilePath & "/" & archiveFile
            move entries of project named "Archive" of document named currentFile to end of entries of document named archiveFile
            save document named archiveFile
            close document named archiveFile
        end tell
    end if
end tell

edit: added file check, lost some archived task due missing file check.

Alternate Version

This version is based on the above script, but pulls tasks from the front most file open in TaskPaper, rather than a single fixed file. It also deletes the archive project after removing all the tasks.

property archiveFile : "Archive.txt" 
property archiveFilePath : "/path/to/archive/file"

tell application "Finder"
    if exists (archiveFilePath & "/" & archiveFile) as POSIX file then
        tell application "TaskPaper"
            set currentFile to name of front document
            open archiveFilePath & "/" & archiveFile
            move entries of project named "Archive" of document named currentFile to end of entries of document named archiveFile
            delete project named "Archive" of document named currentFile
            save document named archiveFile
            close document named archiveFile
        end tell
    end if
end tell