Script Command to "Sort By Name" inside all folders

Is there a script command to sort by name all the folders of the project?
How can I execute that automatically every time I open the project?

many thanks


There’s no single script function to sort all folder in a project by name. However, this can be done by enumerating them, and sorting them yourself by operating on the ManagedRelationship of a given folder using the ManagedRelationship functions. For example, I can swap the positions of two events in an event folder that I’ve selected in the event editor with the following:

var firstEvent = studio.window.browserCurrent().relationships.items.destinations[0];
studio.window.browserCurrent().relationships.items.insert(1, firstEvent);

As for executing script automatically on opening a project, there unfortunately exists no callback for doing so. That said, I’ve noted it on our internal feature/improvement tracker.