Create new folder in DO13

Thank you, we are almost there.

Now, if I press CTRL+N, the first thing it does is to open the highlighted folder and then the "New folder" dialog appears.

image

I don't want the highlighted folder to open, just a new subfolder being created inside. Just like CTRL+O does now.

Thanks again!

Try

// https://resource.dopus.com/t/create-new-folder-in-do13/48420/22
// 2024-05-03

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;

    if (tab.selected_dirs.count > 0) {
        cmd.SetSource(tab.selected_dirs(0));
    }
    
    cmd.RunCommand('CreateFolder');
}
XML
<?xml version="1.0"?>
<button backcol="none" display="both" hotkey="ctrl+N" textcol="none">
	<label>New Folder 48420</label>
	<icon1>#makedir</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/create-new-folder-in-do13/48420/22</instruction>
		<instruction>// 2024-05-03</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    if (tab.selected_dirs.count &gt; 0) {</instruction>
		<instruction>        cmd.SetSource(tab.selected_dirs(0));</instruction>
		<instruction>    }</instruction>
		<instruction>    </instruction>
		<instruction>    cmd.RunCommand(&apos;CreateFolder&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

I am very sorry, I know it is annoying but I am not an expert so I need a step-to-step guide to use the code you provided. I don't even know where to put it.

See How to use buttons and scripts from this forum.

Again, thank you.
But why a button? I needed it to be associated to CTRL+N.

Just like the stock button

image

No hard feelings if you convert it to a pure hotkey :slight_smile:

It worked, thank you!