JSI Tip 9115. How can I add a 'New Folder' command to a folder's right-click context menu?

I have scripted a MakeNewFolder.bat file to add a New Folder command when you right-click a folder in Windows Explorer.

The MakeNewFolder.bat script creates a %SystemRoot%\NewFolder.bat file that prompts the user for a folder name, and a temporary file that REGEDIT uses to add the New Folder command to a folder's context menu.

The syntax for using MakeNewFolder.bat is MakeNewFolder.

When a user right-clicks on a folder, and clicks the New Folder command, they will be prompted with:

Type the Folder Name and press Enter. 
If they press Enter, the NewFolder.bat script will exit. If they type a new folder name, like This is a new sub-folder, a new sub-folder will be created. Notice that quotes (") should NOT be used.

MakeNewFolder.bat contains:

@echo off
set nf="%TEMP%\NF_%RANDOM%.TMP"
@echo @echo off>%SystemRoot%\NewFolder.bat
@echo if \{%%1\}==\{\} goto :EOF>>%SystemRoot%\NewFolder.bat
@echo setlocal>>%SystemRoot%\NewFolder.bat
@echo pushd %%1>>%SystemRoot%\NewFolder.bat
@echo set ANS=\{NONE\}>>%SystemRoot%\NewFolder.bat
@echo set /p ANS="Type the Folder Name and press Enter. ">>%SystemRoot%\NewFolder.bat
@echo if "%%ANS%%" EQU "\{NONE\}" endlocal^&goto :EOF>>%SystemRoot%\NewFolder.bat
@echo MD "%%ANS%%">>%SystemRoot%\NewFolder.bat
@echo popd>>%SystemRoot%\NewFolder.bat
@echo endlocal>>%SystemRoot%\NewFolder.bat
@echo Exit>>%SystemRoot%\NewFolder.bat
@echo REGEDIT4>%nf%
@echo \[HKEY_CLASSES_ROOT\Folder\shell\NewFolder\]>>%nf%
@echo @="New Folder">>%nf%
@echo \[HKEY_CLASSES_ROOT\Folder\shell\NewFolder\command\]>>%nf%
set work=%SystemRoot%
set work=%work:\=\\%
@echo @="%work%\\System32\\cmd.exe /k %work%\\NewFolder.bat \"%%1\"">>%nf%
regedit /s %nf%
del /q %nf%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.