Create new file
Moderators: Hacker, petermad, Stefan2, white
Create new file
How can I just create a new file - let's say dummy.doc - with a TC native command or shortcut?
Shift-F4 creates dummy.doc, but will open it in a text editor.
Context menu New > ... requires a long wait and lacks a keyboard shortcut
Shift-F4 creates dummy.doc, but will open it in a text editor.
Context menu New > ... requires a long wait and lacks a keyboard shortcut
-
- Power Member
- Posts: 872
- Joined: 2013-09-04, 14:07 UTC
Re: Create new file
UPDATE: Having seen Stefan2's answer, i now realize that i probably have misunderstood your question (unless you really want to create new zero-sized files). So, please ignore my suggestion...
I have not really found a satisfactory way to do this with TC's built-in capabilities. I know of a way that kinda works, but which has a number of shortcomings.
If you create a toolbar button or a user command with
Command:
Parameter:
(yes, just a question mark)
If you invoke the button or the user command, you will get a dialog box where you can enter the file name to create. created file will be empty (file size of 0 bytes). The base/working directory for this operation is naturally the directory of the active file panel. [*]
However, this approach suffers from some problems i found no solution for:
Maybe someone else has a clever idea (outside of scripting with Powershell, AHK, or the likes) that sucks less than my approach...
[*] In case you wonder how this works: 2> redirects the error output channel of the cmd.exe invocation into the file whose name is being aquired by the ? parameter. Since "cmd.exe /c echo." is not expected to produce any error output at all, you will end up with an empty file.
I have not really found a satisfactory way to do this with TC's built-in capabilities. I know of a way that kinda works, but which has a number of shortcomings.
If you create a toolbar button or a user command with
Command:
Code: Select all
cmd.exe /c echo. 2>
Code: Select all
?
If you invoke the button or the user command, you will get a dialog box where you can enter the file name to create. created file will be empty (file size of 0 bytes). The base/working directory for this operation is naturally the directory of the active file panel. [*]
However, this approach suffers from some problems i found no solution for:
- The dialog box does not ask for a file name, but for "command line parameters". I find this confusing.
- File names with whitespaces need to be manually quoted and other special characters escaped with ^, which makes the whole thing cumbersome imo.
- If you provide a file name/path that is invalid or contains illegal characters, who knows what will happen. Probably either nothing, or some other surprising crap. Treat it like walking on eggshells.
- It does not work if the directory of the active panel is an UNC path. Paths from fIle system plug-ins are also likely preventing this from working.
- If you use this frequently enough in different circumstances, you might stumble over other shortcomings i am not aware of right now...
Maybe someone else has a clever idea (outside of scripting with Powershell, AHK, or the likes) that sucks less than my approach...

[*] In case you wonder how this works: 2> redirects the error output channel of the cmd.exe invocation into the file whose name is being aquired by the ? parameter. Since "cmd.exe /c echo." is not expected to produce any error output at all, you will end up with an empty file.
Last edited by gdpr deleted 6 on 2020-10-28, 18:11 UTC, edited 1 time in total.
Re: Create new file
cm_EditFileMenu
cm_EditFileMenu=2943;Show 'New' menu from context menu
- - -
To assign an keyboard shortcut key (hotkey) to an command,
utilize "Configuration > Options > Misc. >>> Redefine hotkeys (Keyboard remapping)".
* Open "Configuration > Options > Misc."
* by "()Hotkey" choose a free key combo as keyboard shortcut
--or--
* by "()Alias" enter a few digits-or-letters for to use in TCs command line box
* For Command: click on the magnifying glass
* Choose the wanted command by double clicking on it.
(To filter type em_ or cm_ and maybe more letters or just an keyword like 'copy')
* Apply with the green check mark button!!!
* Close the options dialog with [OK]
* Click on OK
cm_EditFileMenu=2943;Show 'New' menu from context menu
- - -
To assign an keyboard shortcut key (hotkey) to an command,
utilize "Configuration > Options > Misc. >>> Redefine hotkeys (Keyboard remapping)".
* Open "Configuration > Options > Misc."
* by "()Hotkey" choose a free key combo as keyboard shortcut
--or--
* by "()Alias" enter a few digits-or-letters for to use in TCs command line box
* For Command: click on the magnifying glass
* Choose the wanted command by double clicking on it.
(To filter type em_ or cm_ and maybe more letters or just an keyword like 'copy')
* Apply with the green check mark button!!!
* Close the options dialog with [OK]
* Click on OK
Re: Create new file
AskParam tool may be useful for this.elgonzo wrote: 2020-10-28, 16:58 UTC ...
Command:Parameter:Code: Select all
cmd.exe /c echo. 2>
(yes, just a question mark)Code: Select all
?
If you invoke the button or the user command, you will get a dialog box where you can enter the file name to create. created file will be empty (file size of 0 bytes). The base/working directory for this operation is naturally the directory of the active file panel. [*]
However, this approach suffers from some problems i found no solution for:
- The dialog box does not ask for a file name, but for "command line parameters". I find this confusing.
Windows 11 Home, Version 24H2 (OS Build 26100.4061)
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
- MarkFilipak
- Member
- Posts: 164
- Joined: 2008-09-28, 01:00 UTC
- Location: Mansfield, Ohio
Re: Create new file
Zero-length file?
Here's what I do:
type>"NAMEOFFILE"
You don't have to do anything except start typing. The command line box opens with the first keystroke.
Here's what I do:
type>"NAMEOFFILE"
You don't have to do anything except start typing. The command line box opens with the first keystroke.
Hi Christian! Delighted customer since 1999. License #37627
Re: Create new file
@All: Thanks!

That is exactly what I want to do: create zero (or two or ..) byte files to use as a test-set for the scripts I write
In this case it was for for a TC-button-bar function. Typically I do these things from a (CMD/PowerShell) prompt.
It works, but has the side-effects you already mentioned (and another: "" are required if the filename contains spaces.
P.S. Instead of echo. , you can use almost anything. This is what I use most:
- copy nul file.txt
- set RANDOM=>file.txt
- goto>file.txt
(Works very well. Big advantage: no issues with problematic characters and spaces in the filename).
I thought that the command-line was executed by the shell (=Explorer). You learn every day .. thanks!
If the fielname contains spaces, it should be in "" too.
BTW: this works too, although I don't know why:
Conclusion: There is no native out-of-the box way to do this, but there are a couple of good "roll your own" workarounds.
Problem solved, case closed.
No, I will notelgonzo wrote: 2020-10-28, 16:58 UTC UPDATE: Having seen Stefan2's answer, i now realize that i probably have misunderstood your question (unless you really want to create new zero-sized files). So, please ignore my suggestion...

That is exactly what I want to do: create zero (or two or ..) byte files to use as a test-set for the scripts I write
In this case it was for for a TC-button-bar function. Typically I do these things from a (CMD/PowerShell) prompt.
It works, but has the side-effects you already mentioned (and another: "" are required if the filename contains spaces.
P.S. Instead of echo. , you can use almost anything. This is what I use most:
- copy nul file.txt
- set RANDOM=>file.txt
- goto>file.txt
That was I was tinkering with too! But missed a way to set a a keyboard shortcut. Very clear explanation.Thanks!
(Works very well. Big advantage: no issues with problematic characters and spaces in the filename).
MarkFilipak wrote: 2020-10-28, 18:17 UTC type>"NAMEOFFILE"
You don't have to do anything except start typing. The command line box opens with the first keystroke.

If the fielname contains spaces, it should be in "" too.
BTW: this works too, although I don't know why:
Code: Select all
.>file.txt
Conclusion: There is no native out-of-the box way to do this, but there are a couple of good "roll your own" workarounds.
Problem solved, case closed.
VBScript: Create new file (Shift+F4 ; ALt+F4)
To create a new (zero-sized, zero-byte) file you can also use putfile.exe by m^2
viewtopic.php?p=136366#p136366
(some way down there is the file also as Base64)
Create an user defined command for calling that tool, next assign a Keyboard shortcut or an Alias to execute that UDC
( FAQs: User-Defined Command (UDC) (usercmd.ini) em_command >>> viewtopic.php?p=344777#p344777 )
- - -
For others:
TC default to create a new text file is Shift-F4 (F7 to create an folder)
TCs internal command to utilize Context menu "New >"-entry, is cm_EditFileMenu
In the forum there are dozens posts with tips how to create files with TC. There is almost nothing you can't do.
- - -
Or create your own external script (batch, powershell, autohotkey, VBS)
Create an userdefined command for calling that script, next... see above.
Here is my current used script:
viewtopic.php?p=136366#p136366
(some way down there is the file also as Base64)
Create an user defined command for calling that tool, next assign a Keyboard shortcut or an Alias to execute that UDC
( FAQs: User-Defined Command (UDC) (usercmd.ini) em_command >>> viewtopic.php?p=344777#p344777 )
- - -
For others:
TC default to create a new text file is Shift-F4 (F7 to create an folder)
TCs internal command to utilize Context menu "New >"-entry, is cm_EditFileMenu
In the forum there are dozens posts with tips how to create files with TC. There is almost nothing you can't do.
- - -
Or create your own external script (batch, powershell, autohotkey, VBS)
Create an userdefined command for calling that script, next... see above.
Here is my current used script:
Code: Select all
REM https://ghisler.ch/board/viewtopic.php?p=393702#p393702
REM Re: Create new file - Post by *Stefan2 » Wed Oct 28, 2020 21:28
REM
REM UserCmd.ini
REM [em_CreateNewTextFileF4VBS]
REM CMD=%Commander_Path%\TOOLs\CMDs\CreateNewTextFileF4.vbs
REM
REM WinCmd.ini[Shortcuts]
REM ;Disable 'Alt+F4' (Exit, close program)
REM A+F4=em_CreateNewTextFileF4VBS
'//------------------
'CreateNewTextFile.vbs 2014-04-22 Thu 17:22:18
On Error Resume Next
'// Get timestamp
N = Now
W = WeekdayName( Weekday(N), true)
D = Year(N) & "-" & Right("00" & Month(N), 2) & "-" & Right("00" & Day(N), 2)
T = Right("00" & Hour(N), 2) & Right("00" & Minute(N), 2) & Right("00" & Second(N), 2)
'// Vorlage: 2009-08-16 081346 # STEP .TXT
MyTimeStamp = D & " " & T
'//------------------
NewFileName = InputBox("Enter file name to create new:" &vbLF _
& "Add a ? -sign somewhere to open the file in editor", "Total Commander", MyTimeStamp & " # .txt?" )
If NewFileName="" Then WScript.Quit
'//------------------
'//TRICK: use "?" sign in new file name to open the text file after creation:
IF (InStr(NewFileName,"?")) Then
NewFileName = Replace(NewFileName,"?","")
CreateObject("Scripting.FileSystemObject").CreateTextFile(NewFileName)
SET WSO = WScript.CreateObject("WScript.Shell")
TCPath = WSO.ExpandEnvironmentStrings("%Commander_Path%")
If (FileExist(TCPath & "\TOOLs\NotePad2\notepad2.exe")) Then
myEditor = TCPath & "\TOOLs\NotePad2\notepad2.exe "
Else
myEditor = "notepad.exe "
End If
REM msgbox myEditor
'//WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=minimize 3=maximize ...] [,bWaitTillFinish? True/defaultFalse]
WSO.run myEditor & " " & NewFileName
SET WSO = Nothing
Else
'// Just create the file and leave
CreateObject("Scripting.FileSystemObject").CreateTextFile(NewFileName)
End If
'//------------------
- MarkFilipak
- Member
- Posts: 164
- Joined: 2008-09-28, 01:00 UTC
- Location: Mansfield, Ohio
Re: Create new file
Thank you! That's even easier than 'type>'.
Code: Select all
.>"I use zero-length files to add comments to folders, documentation, thoughts, etc"
Hi Christian! Delighted customer since 1999. License #37627
-
- Power Member
- Posts: 872
- Joined: 2013-09-04, 14:07 UTC
Re: Create new file
It's how the cmd.exe shell works. Some error message will be printed, however the error message is being printed to stderr, not stdout. Therefore, if the command fails, there is no data in stdout and the redirection target file won't receive any data and will stay empty.NotNull wrote: 2020-10-28, 20:08 UTC BTW: this works too, although I don't know why:Code: Select all
.>file.txt
By the way, it never crossed my mind before to exploit the command line in this way, and ".>some.txt" is pretty awesome, especially if you have a keyboard layout where "." and ">" are on the same physical key or next to each other.

Re: Create new file
I don't think that the command is executed by cmd. (try to execute "pause" for example)
This is how the command-line engine looks to me:
- Check if it is a command that TC knows how to handle internally (cm_... and apparently "type" too). If so: execute it.
- Check if the command is a valid filename (Check current directory, %PATH% and AppPath regkeys for that)
If yes: pass it along to a Windows ShellExecute routine (or similar).
If No: let TC throw error.
"." is a valid (relative) foldername. exeuting "." would be similar to exeuting "c:\windows": both will start File Explorer. ("." would open File Explorer in the current active TC folder, similar to "start ." in CMD)
But why .> has a meaning to TC is beyond me ...
(As a test I also created cm_versioninfo.exe. Executing cm_versioninfo did start the TC command and not the exe)
-
- Power Member
- Posts: 872
- Joined: 2013-09-04, 14:07 UTC
Re: Create new file
Sure, TC has inspect/parse the command line parsing first by itself, otherwise it wouldn't be able to execute TC's commands and such.
Still, for this construct ".>yumm.txt" here in discussion it rather looks like to be executed within a cmd.exe shell:
- There is a console window popping up for a very brief moment when this is being executed. Might not always be noticable, though.
- If you execute the construct in a cmd shell, you will see an error message. Note that this error message is not printed to stdout, but stderr, hence why it is not redirected into the file. But if you do a redirection of stderr like ". 2>some.txt" (the space is important!), you'll see the error message in the file. You will see the same error message being redirected when using TC's command line.
You seem to be mistaken here because you believe TC understands and executes the ".>some.txt" in the same manner as it would ".". But it does not."." is a valid (relative) foldername. exeuting "." would be similar to exeuting "c:\windows": both will start File Explorer. ("." would open File Explorer in the current active TC folder, similar to "start ." in CMD)
But why .> has a meaning to TC is beyond me ...
TC recognizes the redirection symbol ">" and as a consequence does not try to interpret and execute the command line internally but rather hands it off to cmd.exe (or %COMSPEC%, if you will). Observe that "." alone opens the explorer window, whereas ". 2>some.txt" (redirecting stderr; mind the space) is not opening explorer while yielding a file containing the error message as you would see in cmd.exe (as well as the brief blink of a cmd.exe window appearing and closing again).
It is interesting to see the result of executing(As a test I also created cm_versioninfo.exe. Executing cm_versioninfo did start the TC command and not the exe)
Code: Select all
cm_versioninfo >some.txt
(EDIT: Yes, ten edits. Proof that i can't write legible English even if my life depended on it...)
Last edited by gdpr deleted 6 on 2020-10-29, 13:46 UTC, edited 10 times in total.
- MarkFilipak
- Member
- Posts: 164
- Joined: 2008-09-28, 01:00 UTC
- Location: Mansfield, Ohio
Re: Create new file
This has nothing to do with TC.
works in a termainal window, too, outside of TC.
Code: Select all
.>"This is foo"
Code: Select all
P:\>dir
Volume in drive P is VideosP
Volume Serial Number is FE5A-E574
Directory of P:\
19-10-09 18:05 0 Firmware Revision = 1014
19-10-09 18:07 0 Serial Number = WX21DC8HRP6J
2 File(s) 0 bytes
0 Dir(s) 4,000,439,599,104 bytes free
P:\>.>"this is foo"
'.' is not recognized as an internal or external command,
operable program or batch file.
P:\>dir
Volume in drive P is VideosP
Volume Serial Number is FE5A-E574
Directory of P:\
19-10-09 18:05 0 Firmware Revision = 1014
19-10-09 18:07 0 Serial Number = WX21DC8HRP6J
20-10-29 09:26 0 this is foo
3 File(s) 0 bytes
0 Dir(s) 4,000,439,599,104 bytes free
P:\>
Hi Christian! Delighted customer since 1999. License #37627
Re: Create new file
Yes I was!
I had the nagging feeling that my theory wasn't right, so I spent a large part of my free afternoon figuring out what is going on with the command-line (instead of repairing a sewing machine; I might be in trouble ...

This is what I found out thus far (and that corresponds with your findings).
Posting them so my time wasn't *entirely* wasted:
- Check if it is a command that TC knows how to handle internally (cm_... and cd [1] ). If so: execute it.
- If no: continue with:
- Check if the command contains a > or starts with (read till space detected) one of the keywords from an (internal TC) list [2]
- If yes, start C:\Windows\System32\cmd.exe /C with the text that was on the TC command-line
- If no: continue with:
- Check if it starts with a valid filename (Check current directory, %PATH% and AppPath regkeys for that)
- If yes: pass it along to a Windows ShellExecute routine (or similar).
- If No: let TC throw error: File not found.
A couple of thing I noticed:
- You can do a DIR & PAUSE and the CMD window will stay open. That is not the case with other command: For example ATTRIB & PAUSE closes immediately
- You have to use a space before the "&" : dir&pause will not work as expected. MAkes a bit sense, as I might have a program like search&destroy.exe
- As a > will switch to "CMD-mode", you can capture normal output AND error output (STDOUT and STDERR) by using an unused output stream:
. That way STDOUT and STDERR will not be redirected. No internal command will use the "3" output stream (or the 4-9 ones).
Code: Select all
ATTRIB & PAUSE 3>nul
Another way of writing this (this is supported CMD syntax):That makes it easier to re-use the command: type 3, followed by CTRL+DOWN and there you are ..Code: Select all
3>nul ATTRIB & PAUSE
Note: As the detected > will already switch to CMD-mode, now you don't have to use a space after attrib: 3>nul ATTRIB&PAUSE
But it might be easier to start CMD and enter your commands there.
[1]
the CD command is handled internally (without using cmd for that.
Proof 1: You can issue command cd X:\folder when you are currently in C:\ . cmd requires CD /d x:\folder for that
Proof 2: CD /? doesn\t start cmd.
[2]
- Not all internal commands are valid on the TC command-line.
- Some make sense (no use for - for example - SETLOCAL, GOTO, PROMPT).
- Others have synonyms that are not supported (REN = ok; RENAME = not. same for MD vs MKDIR, DEL vs ERASE, cd vs CHDIR).
- COPY is supported; MOVE is not (!)
- Some could be useful, but are not on the TC-list: FOR, IF, MKLINK, FTYPE, ASSOC (FYI: ftype and assoc require elevation as they write to the HKLM registry; running TC elevated still didn't support them)