Guest User

Untitled

a guest
Feb 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. (*
  2. Manage GTD Projects within Entourage
  3. by Rich Corbridge
  4. If you enhance/extend this please drop me a copy at rich.corbridge AT gmail.com.
  5. *)
  6. tell application "Microsoft Entourage"
  7. -- get the currently selected task
  8. set theTasks to selection
  9.  
  10. -- if there are no tasks selected, warn the user and then quit
  11. if theTasks is {} then
  12. display dialog "Please select a task first and then run this script." with icon 1
  13. return
  14. end if
  15.  
  16. repeat with theTask in theTasks
  17.  
  18. -- get the information from the message, and store it in variables
  19. set theName to name of theTask
  20. set theCategory to category of theTask
  21. set theProject to project list of theTask
  22. set thePriority to priority of theTask
  23. set theContent to content of theTask
  24. set theDueDate to due date of theTask
  25. set theLinks to links of theTask
  26.  
  27. set Pos to offset of "] - " in theName
  28. set projectName to (text 1 thru Pos of theName)
  29. set lastAction to (text (Pos + 2) thru -1 of theName)
  30.  
  31. set tempContent to theContent
  32. set foundAll to 0
  33. set actions to {}
  34.  
  35. repeat until (foundAll = 1)
  36. set returnPos to offset of return in tempContent
  37. if returnPos = 0 or returnPos = 1 then
  38. set foundAll to 1
  39. else
  40. set tempAction to (text 1 thru (returnPos - 1) of tempContent)
  41. set actions to actions & tempAction
  42. if (returnPos + 1) < (length of tempContent) then
  43. set tempContent to (text (returnPos + 1) thru (length of tempContent) of tempContent)
  44. else
  45. set foundAll to 1
  46. end if
  47. end if
  48. end repeat
  49.  
  50. set actionsCount to count of actions
  51. set nextActionText to ""
  52. if actionsCount is greater than 0 then
  53. repeat with i from 1 to actionsCount
  54. if item i of actions = lastAction and i + 1 ² actionsCount then
  55. set nextActionText to item (i + 1) of actions
  56. end if
  57. end repeat
  58. end if
  59.  
  60. if nextActionText > "" then
  61. set nextAction to projectName & " " & nextActionText
  62. -- create a new task with the information from the old task and the next action
  63. set newTask to make new task with properties {name:nextAction, content:theContent, category:theCategory, project list:theProject, priority:thePriority, due date:theDueDate}
  64.  
  65. set theLinksCount to count of theLinks
  66. if theLinksCount is greater than 0 then
  67. -- open newTask to add link
  68. open newTask
  69. display dialog "There were some links that couldn't be carried over."
  70. end if
  71. end if
  72. set theTask's completed to true -- set the old Task to complete
  73. end repeat
  74. end tell
Add Comment
Please, Sign In to add comment