This provides a listing separated by the main parent group in the root…
tell application id "DNtp"
tell current database
set groupList to {}
set allParents to (parents whose (location is "/") and (type is not smart group)) -- This processes the root parents
repeat with theParent in allParents
if (name of theParent) is not in {"Tags", "Trash"} then
copy (name of theParent & ":" & return) to end of groupList
my processParent(theParent, groupList)
copy return to end of groupList
end if
end repeat
create record with {name:(name & " Listing" as string), content:groupList as string, type:txt} in root
end tell
end tell
return groupList as string
on processParent(theParent, groupList)
tell application id "DNtp"
set theKids to (children of theParent whose (type is group))
if theKids is not {} then
repeat with theChild in theKids
copy (name of theChild & return) to end of groupList
my processParent(theChild, groupList)
end repeat
end if
end tell
end processParent