Collapse groups with AppleScript

Is it possible to collapse a group with a certain UUID via AppleScript?
I intend to write an AppleScript that collapses all open groups but I already fail with the first command.
ChatGPT suggests the following, but that doesn’t work:

tell application id "DNtp"
    set theGroup to get record with uuid "7718548A-..."
    set collapsed of theGroup to true
end tell

What does the program have to say to the fact that its solution “doesn’t work”?


ChatGPT doesn’t produce usable AppleScript.

(It probably hasn’t seen enough AppleScript to be able to generate more than a kind of satirical pastiche, and it contains no model at all of what things are based on, or whether they work).

1 Like

Do you mean that there are other languages for which it can produce something usable?


Chatpgt has already helped me to adapt another script so that it works.
Do you know another way to close a group via script? I can do it manually with klicking on > (triangle) and holding ⇧⌥
When I open a workspace there are many open groups and I cannot get rid of them.

other languages for which it can produce something usable ?

It produces more usable material where it has seen much more, and built a richer statistical model.

Can be good for generic JS, for example.

(The AS corpus is just too small, and too fragmented by the differing object models of each application. DEVONthink parents don’t have a collapsed property, though properties of that name may be been seen in AppleScript code – for other applications)

Of course, it involves no model of what works and why, but if thousands of creatures are moving continuously through the forest, it can form a fairly high-resolution statistical map of which paths are most well worn, and in a certain type of context the best-worn cliché can happen to be what you need.

1 Like

I did not get any usable result with JXA.
Now I have solved it with Hauruck-method (with chatgpt). It calls ⌘a and then ←

tell application "System Events"
	keystroke "a" using command down
	delay 0.2
	key code 123
end tell

Good to have an AI.

It helps me to learn some AppleScript.

Like that idea and will use your snippet to put a nice Actionbutton for this in my DT-Toolbar :stuck_out_tongue_winking_eye: Thanks!