View Single Post
Looks very useful :-)

(I notice that it only reaches down to one level of folder indentation, and that may well be all that you are using. If, however, you do want it to find folders at an arbitrary depth of nesting (and correspondingly extend the MD header ### sequences) you could make some edits broadly along the following lines)

Code:
on run
	tell application "OmniFocus"
		set dteNow to (current date)
		set ExportList to "Current List of Active Projects" & return & "---" & return & dteNow & return & return as Unicode text
		tell default document
			repeat with oFolder in (flattened folders where hidden is false and name is not "Personal" and name is not "Management" and name is not "Someday/Maybe") as list
				set ExportList to ExportList & my IndentAndProjects(oFolder, dteNow) & return
			end repeat
			
			set ExportList to ExportList & return & return & "Completed Tasks" & return & "---" & return & return
			set week_ago to dteNow - 7 * days
			
			set refDoneInLastWeek to a reference to (flattened tasks where (completion date ≥ week_ago) and name of folder of its containing project is not "Personal" and name of folder of its containing project is not "Management" and name of folder of its containing project is not "Someday/Maybe")
			set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of refDoneInLastWeek
			set strText to ""
			repeat with iTask from 1 to length of lstName
				set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
				if varDate is not missing value then set strText to strText & short date string of varDate & " - "
				if varProject is not missing value then set strText to strText & " [" & varProject & "] - "
				set strText to strText & strName
				if varContext is not missing value then set strText to strText & " @" & varContext
				set strText to strText & "  " & return
			end repeat
		end tell
		
		set ExportList to ExportList & strText as Unicode text
		
		set fn to choose file name with prompt "Name this file" default name "Weekly Development Report" & ".md" default location (path to desktop folder)
		tell application "System Events"
			set fid to open for access fn with write permission
			write ExportList to fid
			close access fid
		end tell
	end tell
end run


on IndentAndProjects(oFolder, dteNow)
	tell application id "OFOC"
		set strIndent to "##"
		set oParent to container of oFolder
		repeat while class of oParent is folder
			set strIndent to strIndent & "#"
			set oParent to container of oParent
		end repeat
		
		set {dlm, my text item delimiters} to {my text item delimiters, return & return}
		set strActive to (name of (projects of oFolder where it is not singleton action holder and its status is active and its start date is missing value or start date < dteNow)) as string
		set my text item delimiters to dlm
		
		return strIndent & name of oFolder & return & strActive & return
	end tell
end IndentAndProjects

Last edited by RobTrew; 2012-01-29 at 02:25 PM..