View Single Post
I have been asked how one can get the full path of a project that may be nested within one or more folders.

The following snippet includes some elements that could be reused:
Code:
on run
	tell application id "OFOC"
		
		tell front document window of front document
			repeat with oPanel in {sidebar, content}
				set lstValue to value of (selected trees of oPanel where class of its value is project)
				set lngProj to count of lstValue
				if lngProj > 0 then exit repeat
			end repeat
			if lngProj < 1 then return
		end tell
	end tell
	set oProject to first item of lstValue
	
	set lstPath to ProjectPath(oProject)
	
	set {dlm, my text item delimiters} to {my text item delimiters, "/"}
	set strPath to lstPath as Unicode text
	set my text item delimiters to dlm
	
	set strPath to do shell script ("printf '%q' " & quoted form of strPath)
end run

on ProjectPath(oProject)
	tell application id "OFOC"
		tell oProject
			set lstPath to {name}
			set oContainer to container
		end tell
		
		repeat while class of oContainer is not document
			set beginning of lstPath to name of oContainer
			set oContainer to container of oContainer
		end repeat
	end tell
	lstPath
end ProjectPath