Create Travel Checklists with AppleScript for Omnifocus

In the show notes for Automators#5, Rosemary linked to an article at Coding Bull Junky about an AppleScript for making a travel checklist in Things. I wanted something similar for Omnifocus. And because I have different checklists and packing lists depending on whether I’m traveling domestically or internationally, in cold weather or hot weather, or if I’m going camping with the family, I wanted a bunch of different possible checklists.

There are at least two ways to improve this. First, if I used conditional branching, this could all be in one script. Second, if I knew how to do date math in AppleScript, I could create due dates based on the departure date (because some checklist items are things that need to be done before the date of departure.)

Cold Domestic Travel Packing List

display dialog "What is the duration of your trip (in days)?" default answer "7"
set theNumber to text returned of result as number
set theHalfNumber to (round (theNumber / 2))
display dialog "What is the destination or name of your trip?" default answer "Vacation"
set projectName to text returned of result as string

if theNumber > 14 then
	set theNumber to "14"
end if

if theHalfNumber > 5 then
	set theHalfNumber to "5"
end if

set theNumber to theNumber as string
set theHalfNumber to theHalfNumber as string

set theNonNumberedList to {"Dress Shoes", "Sneakers", "Sweater", "Jackets/Raincoat", "Belt", "Pajamas", "Toiletries", "Glasses", "Sunglasses", "Watch", "AirPods", "Phone", "Camera", "iPad", "Macbook", "Cords for charging", "Kindle", "Itinerary", "Keys", "Cash", "Pillow", "Music", "Movies", "Hat", "Gloves", "Scarf"}
set theOneperDayList to {"Underwear", "Socks"}
set theHalfperDayList to {"Pants", "T-shirts", "Collared shirts"}

tell front document of application "OmniFocus"
	set homeContext to first flattened context whose name is "Packing"
	set theProject to make new project with properties {name:projectName, context:homeContext, sequential:true}
	tell theProject
		repeat with eachItem in theNonNumberedList
			make new task with properties {name:eachItem}
		end repeat
		repeat with eachItem in theOneperDayList
			make new task with properties {name:theNumber & " " & eachItem}
		end repeat
		repeat with eachItem in theHalfperDayList
			make new task with properties {name:theHalfNumber & " " & eachItem}
		end repeat
		
	end tell
end tell
1 Like