CreateFolder and RunCommand creating sub-folder when run twice

if CreateFolder NAME="foo folder" is put on a button and clicked a folder will be created, if clicked again nothing will happen.
if clickData.func.command.RunCommand('CreateFolder NAME="foo folder"'); is run (the same command just run from a script) the folder will be created, if it is run again a sub-folder will be created of the same name inside the already existing folder.
How do I prevent this ?

Try this:

clickData.func.command.RunCommand('CreateFolder NAME="{sourcepath}foo folder"');

Many thanks that works :slight_smile:

I looked into what was happening, and we'll have a fix for this in the next beta. (May not be in 12.29 if there isn't another beta before that.)

The way scripts run the command was being treated similar to how the command is run from a context menu, where if there's a selected folder (assumed the one right-clicked to show the context menu) it's meant to create things under that folder. Doesn't make sense for that to happen with scripts, though, so we've changed it.

Another way to avoid the problem, while still using the original command, would be to call ClearFiles on the command object before running the command.