Possible to Create Asset Folder from Script? Also NavigateTo does not target AssetFolders

Per this topic it seems like you can’t Create an asset folder from script? Seems to still not be the case in 2.03. YOu can do so via right click in the asset browser to create a new empty folder though so would be great if this could be exposed, especially since FMOD can’t target the folder as a move target until an audio file is in it.

Also, studio.window.navigateTo() does not target asset folders, however it targets assets. Is this a bug?

Update: also according to this topic you should be able to have a folder created by just using setAssetPath() on the asset. This only kind of works, the folder and assetFolder will get created, but the folder shows as “unimported”, attempting to import it will delete all the files inside of it.

Update 2: Found a workaround, you can use a window trigger action to create a new folder. THe new folder is automatically selected so you can grab it with broswerCurrent and then set its name and that will validate it. This assumes you are in the Assets tab of the editor:

studio.window.triggerActions(studio.window.actions.NewBrowserFolder)
newFolder = studio.window.browserCurrent()
newFolder.setAssetPath(path)

Hi,

Thank you for sharing the workaround, would it be possible to share the full script so I can test it on my end?

The full script is doing lots of other things so is too long to share in its entirety, the relevant portion is here:

studio.window.open("Audio Bin");
studio.window.triggerAction(studio.window.actions.NewBrowserFolder);
var name = studio.system.getText("name for folder", "default");
newFolder = studio.window.browserCurrent();
newFolder.setAssetPath([INSERT YOUR PATH FOR NEW FOLDER PARENT HERE] + name);

Note: To basically ensure we are in the right context to grab the newly created folder I open the Audio Bin. Then to make sure the UI completes and we don’t call studio.window.browserCurrent() before the folder is selected in GUI I prompt for the folder name

And also wanted to make sure you got the feature request to allow studio.window.navigateTo() to target asset folders

1 Like

That does seem to be a bug. I have passed it to our delopment team to look into further.

Thank you for sharing your code.