How to Create New/Empty Files

If you want to create a button or menu item which creates a new file, in the same way that the "New" context menu creates new files of different types, then you can use a command like this:

FileType NEW=.txt

The command above only works for file types that have a "template" for creating new files; essentially, the types that appear when you right-click the background of Opus or Explorer and open the New menu.

If you have Microsoft Word installed, then this command will create new Word documents:

FileType NEW=.docx

(If that doesn't work or you're using a very old version of Word, try .doc instead of .docx.)

But if you don't have Word installed, the command above may not work, as there probably won't be a template on your system for creating new .doc files. There is a way around that.

The command below works with any file type (.doc is used in the example) and will create an empty file with the specified name and then select the name (not including the extension) so that you can type over it:

FileType NEW=.txt NEWNAME="New Document.doc"

That tells Opus to create a new file using the .txt template (which is always a completely empty file) but to name it "New Document.doc."

The command above is only safe if the programs associated with the file type (.doc in the example) understand what to do with completely empty (0 byte) files. Some programs or file types will not work with this. For example, "empty" zip files must still contain a 22-byte header in order to be valid. Luckily, there is almost always a template zip file so the basic FileType method works fine for them.


Is there a way to make it open the newly created file for editing?

Yes, the Filetype NEW command adds the name of the newly created file to a function variable called newfile so you can do something like this:

Filetype NEW=.txt NEWNAME="{dlgstringS|Enter new file name:|New Text Document}"
notepad "{sourcepath}{$newfile}"
1 Like

Hi there, thanks for the excellent program, which I've been trying out for a long while now..

My question is I would like to to r-click on a folder and have the option to (create text file IN HERE named...) and then open it for editing.

I originally tried, to no avail:

FileType NEW .txt NEWNAME "norename:{dlgstring}.txt" TO fromsel
FileType NEW .txt NEWNAME "norename:{dlgstring}.txt" TO usesel

But i then saw your suggestion directly above, and would like to modify it so that the file is created in the folder i r-clicked on

I hope this is possible

The most simple way to do it is this:

notepad "{filepath}IN HERE.txt"

Notepad will open an existing file in the selected folder named IN HERE.txt or prompt you to create it. It's also working with more than one folders selected.

Perfect! thanks, I modified it to prompt for new name

notepad "{filepath}{dlgstringS|Enter new file name:|New Text Document}.txt"

This one asks for filetype and name and opens the file:

@set type = {dlgchoose|Choose filetype:|Text=.txt+Word-Document=.docx+Excel-Document=.xlsx}
@set name = {dlgstring|Filename:|New}
Filetype NEW={$type} NEWNAME="{$name}"

This example uses Office 2007/2010, if you have an older version remove "x" at the end of the extension (.docx > .doc)!

I like to add .bat and .reg, but you can't simply execute them. Maybe someone could write an if-then for editing (I had no time to have a look at these new DO-features).

Hi Sasa,

Do you think there is a way to carry out your function above but with the file being created INSIDE the selected folder. It seem the Filetype NEW command forces the new file to be created in {sourcepath}? Can it be changed to {filepath}?

Try, I just used Leo's example which does the job for me.

I did try Leo's example but the file appears in the active display not selected folder, probably my syntax is wrong...

Filetype NEW=.txt NEWNAME="{filepath}{dlgstringS|Enter new file name:|New Text Document}"
notepad "{filepath}{$newfile}"

Thanks for the examples everyone. I just combined them to create a working solution for all filetypes (those with registered 'new' handler)...

For adding to the context menu of 'All folders': 'Create New file in here...'

Filetype NEW={dlgchoose|Filetype:|Text=.txt+Word-Document=.docx+Excel-Document=.xlsx} NEWNAME="norename:{dlgstring|Filename:|}"
Copy Move "{$newfile}" TO "{filepath}"
@confirm:Open now for editing? 

No need to use @set

If you use a different editor for your files than notepad, and have the program set as the default editor for that filetype, you can also replace notepad with:

explorer.exe "/edit,{sourcepath}{$newfile}"

Opus added the ability to pass "FileType NEW" the path where you want the new file to be created, so you should be able to do that in a much easier way now (i.e. without having to create the file and then move it).

OK, I've copied the commands from monkin's post into a new button and it creates the new file as expected but when I click OK to open the file for editing, Windows says it can't find the file. Guess I'm doing something wrong

Edit: OK, found the problem. I wasn't adding it to the 'All Folders' context menu, I was using a standard button on a toolbar.

So, can this be made to work with a toolbar button is my next obvious question?


I'm not sure what you want to do. Where do you want the new file created? What do you want to happen after creating it?

Hi Leo,

I would like a button to create new files (text mainly but .docx and .xlsx occasionally). I assumed that the above commands would work as a button on the current source lister. Guess I'll need to look at it a bit closer and see what I can come up with. Don't give me any tips just yet, I'll try and it figure it out. :slight_smile:


If you want to create them in the current source folder, the buttons earlier in the thread are what you want. The one in the 2nd post in the thread is probably what you want.

The purpose of Monkin's command (which can be done in a much better way now anyway) was to do something different to the earlier ones (create the file in the selected folder instead of the current folder).

Thanks Leo, I figured it out in the end.

To create files without extensions:

  1. Use this command:
Filetype NEW=. NEWNAME=empty
  1. Copy the code below, save it as *.reg file and run or just add apt keys/values to Windows registry yourself (if you know how to):
Windows Registry Editor Version 5.00

@="New file (no ext)"




Now you can add button (see code in point 1) and assign a hotkey to it. After you create a new file with no extension, you can type extension from keyboard (filename.ext). It's much easier for me than choosing file type from a drop down list, especially that I have "always show extensions" enabled.

There's no need to mess with the registry for that, just use this as the command:

Filetype NEW=.txt NEWNAME=empty.

If the NEWNAME ends in a . then no extension will be added.

How can the text file be automatically created with the name of the currently selected file + .txt extension?


Selecting "Firefox Setup 20.0.exe" and pressing the button would result in an empty plain text file titled "Firefox Setup 20.0.exe.txt" in the same directory as the original file.

Thank you.