Create new folder in DO13

Thank you! That was really helpful.

I used the second script (quoted above) which creates a folder and names it 'New Folder'. The only issue is that it looks like I can rename it but within a second it auto-saves. Is there a way to get it to wait until I rename it?

Yes, with these modifications:

@nodeselect
@nofilenamequoting
CreateFolder NAME="{filepath}\{dlgstring}"
@nodeselect
FileType NEW=directory PATH={filepath} NEWNAME="{dlgstring}"  

The second button will append a counter if the folder already exists.

4 Likes

That is awesome!! Thanks so much for your help!

This is great, I use it all day. Can I please ask how to automatically expand the directory after creating it?

I have tried to adjust the code below but not finding the right command:

@nodeselect
@nofilenamequoting
CreateFolder NAME="{filepath}\{dlgstring}" 

Add a new line

Go EXPANDBRANCH

Yes I tried this, but it still is collapsed after creating the new folder.

I have attached an example of what I mean. When I create Child_2 its not expanded.

Do you want to expand the folder tree or the file display? Do you want to navigate to the new folder?

File Display. But just that folder after creating it. So for example that code above I create a new folder somewhere in the file display, then i want that to be expanded, but leave everything else as is.

@sendkey:alt+down

seems to work (if you haven't changed the default hotkey).

1 Like

Thanks, This works! You are a life saver. I edited this and removed all the issues I was having (in this post), I restarted dopus and now it works as expected.

Thank you!
Is there a way to link this to the default CTRL+N command? I mean opening the window with all its options (create multiple folders, etc.)?
And do the same with CTRL+O to create a new .txt file?

You could modify the CreateFolder hotkey like this:

Go FROMSEL
CreateFolder
Go BACK

and the FileType hotkey like this:

@nodeselect
FileType NEW=.txt PATH={filepath} NEWNAME="{dlgstring}"
1 Like

Here are your options:
//Displays the parent folder with the new folder unexpanded
Go EXPANDBRANCH
//Displays the parent folder with the new folder expanded
@sendkey:alt+down
//Displays the contents of new folder
Go "{filepath}{$FolderName}"

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!