Make file in windows cmd


Download Article


Download Article

Learning how to do simple file management at the Command Prompt (cmd) comes in handy when you’re learning to code. When you create files and folders at the command line, you can access, use, and manipulate those folders and files in Windows apps. We’ll show you how to create folders (directories) and text files at the Windows Command Prompt, and teach you commands for deleting unneeded files and folders.

  1. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 10

    1

    Open the Command Prompt. The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.

  2. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 11

    2

    Go to the directory in which you want to create the file. The prompt will open to C:\Users\YourName by default. If the directory is somewhere else, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.[1]

    • For example, if you want to create a file on the Desktop, type cd desktop and press Enter.
    • If the directory you’re looking for isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).

    Advertisement

  3. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 12

    3

    Create an empty file. If you don’t want to create an empty file, skip to the next step.[2]
    To create an empty file:

    • Type type nul > filename.txt.
    • Replace filename.txt with whatever you want to call your new file. The «.txt» part indicates that this is a plain text file. Other common file extensions include «.docx» (Word document), «.png» (empty photo),and «.rtf» (rich text document). All of these file types can be read on any Windows computer without installing additional software.
    • Press Enter.
  4. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 13

    4

    Create a file containing certain text. If you don’t want to create a file with certain text inside, skip to the next step.[3]
    Use these steps to create a plain text file that you can type into:

    • Type copy con testfile.txt, but replace testfile with the desired file name.[4]
    • Press Enter.
    • Type some text. This is a rudimentary text editor, but it’s good for quick notes or code. You can use the Enter key to go to the next line.
    • Press Control + Z when you’re finished editing the file.
    • Press the Enter key. You’ll see «1 file(s) copied,» which means your file is now saved with the name you created.
    • Another way to do this is to run this command: echo enter your text here > filename.txt.
  5. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 14

    5

    Create a file that’s a certain size. If you don’t want to create a file that’s a specific size, skip this step.[5]
    To create a blank text file based on byte size, use this command:

    • fsutil file createnew filename.txt 1000.
    • Replace filename with the desired file name, and 1000 with the actual number of bytes you’d like the file to be.
  6. Advertisement

  1. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 15

    1

    Open the Command Prompt. The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.

  2. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 16

    2

    Go to the directory containing the file you want to delete. The prompt will open to C:\Users\YourName by default. If the file is somewhere else, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.

    • For example, if you want to delete a file from the Desktop, type cd desktop and press Enter.
    • If the directory you want to view isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 17

    3

    Type dir and press Enter. This displays a list of all files in the current directory. You should see the file you want to delete in this list.

    • Using Command Prompt to delete files results in the files being deleted permanently rather than being moved to the Recycle Bin. Exercise caution when deleting files via Command Prompt.
  4. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 18

    4

    Type del filename and press Enter. Replace filename with the full name and extension of the file you want to delete.[6]
    File names include file extensions (e.g., *.txt, *.jpg). This deletes the file from your computer.

    • For example, to delete a text file entitled «hello», you would type del hello.txt into Command Prompt.
    • If the file’s name has a space in it (e.g., «hi there»), you will place the file’s name in quotations (e.g., del "hi there").
    • If you get an error that says the file cannot be deleted, try using del /f filename instead, as this force-deletes read-only files.
  5. Advertisement

  1. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 1

    1

    Open the Command Prompt. The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.[7]

  2. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 2

    2

    Go to the directory in which you want to create the new directory. The prompt will open to C:\Users\YourName by default. If you don’t want to create a new directory here, type cd path_to_directory and press Enter. Replace path_to_directory with the actual directory location.[8]

    • For example, if you want to create a directory on your Desktop, you would type in cd desktop and press Enter.
    • If the directory you’re looking for isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 3

    3

    Type mkdir NameOfDirectory at the prompt. Replace NameOfDirectory with the name of the directory you wish to create.[9]

    • For example, to make a directory named «Homework», you would type mkdir Homework.
  4. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 4

    4

    Press Enter. This runs the command to create a folder with the desired name.

  5. Advertisement

  1. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 5

    1

    Open the Command Prompt. The easiest way to do this is to press Win + S to activate the search bar, type cmd, and then click Command Prompt in the search results.[10]

  2. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 6

    2

    Go to the folder containing the directory you want to delete. The prompt will open to C:\Users\YourName by default. If the directory you want to delete is somewhere else, type cd path_to_directory and press Enter.[11]
    Replace path_to_directory with the actual directory location.

    • For example, if you want to delete a directory from your Desktop, type cd desktop.
    • If the directory isn’t in your user directory (e.g., C:\Users\YourName), you’ll have to type in the whole path (e.g., C:\Users\SomeoneElse\Desktop\Files).
  3. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 7

    3

    Type rmdir /s DirectoryName. Replace DirectoryName with the name of the directory you want to delete.[12]

    • For example, if you’re trying to delete your «Homework» folder, you’d type in rmdir /s Homework here.
    • If the directory’s name has a space in it (e.g., «Homework assignments»), place the name in quotations (e.g., rmdir /s "Homework assignments").
  4. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 8

    4

    Press Enter to run the command.[13]

    • If you try to delete a directory that contains hidden files or directories, you’ll see an error that says «The directory is not empty.» In this case, you’ll have to remove the «hidden» and «system» attributes from the files inside the directory. To do this:[14]

      • Use cd to change into the directory you want to delete.
      • Run dir /a to view a list of all files in the directory and their attributes.
      • If you’re still okay with deleting all of the files in the directory, run attrib -hs *. This removes special permissions from the undeletable files.
      • Type cd .. and press Enter to go back one directory.
      • Run the rmdir /s command again to delete the folder.
  5. Image titled Create and Delete Files and Directories from Windows Command Prompt Step 9

    5

    Press y and then Enter to confirm. This will permanently remove the directory.[15]

  6. Advertisement

Add New Question

  • Question

    How can I create directories?

    Subhodeep Roy

    Subhodeep Roy

    Community Answer

    If you are creating a directory in C drive, the command will be»C:\MD {the name of the directory/folder}» then press Enter.

  • Question

    How do I create a folder using CMD?

    Community Answer

    Navigate to where you want the subfolder created and type «mkdir «.

  • Question

    How do I create a test file under the sub folder?

    Community Answer

    Change directory into the new sub folder and then on the next line, create your new test file. For example: cd mysubfolder $ type nul > newtextfile.txt

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Video

Thanks for submitting a tip for review!

  • Using Command Prompt to delete files results in the files being deleted permanently rather than being moved to the Recycle Bin. Exercise caution when deleting files via Command Prompt.

Advertisement

About This Article

Article SummaryX

1. Use the mkdir command to create a folder.
2. Use rmdir /s to delete a folder.
3. Use the copy con or echo command to create a file.
4. Use del to delete a file.
For tips on how to create a file inside a folder, read on!

Did this summary help you?

Thanks to all authors for creating a page that has been read 1,416,523 times.

Is this article up to date?

Knowing how to conduct rudimentary file management at the Command Prompt comes in useful when you’re starting to code. Any file you make from the Command Prompt persists in multiple areas of Windows—this means that generating an index or document at the prompt fixes things so that you can access, utilize, and control that catalog or record in the Windows platform.

There are two ways to create files from the command line. The first method uses the fsutil command, and the second method uses the echo command.

Create File with Echo Command

|echo some-text > filename.txt

Create File with Fsutil Command

|fsutil file createnew filename number_of_bytes

Step-by-Step Process to Create Files via Command Line

STEP 1: Launch the command prompt.

The quickest way to implement this is to open the search bar by pressing Win + S, type cmd, and then select Command Prompt.

STEP 2: Choose the folder where you wish to save the file.

By default, the prompt will open under C:UsersYourName. Suppose the folder is elsewhere; type the cd path to the folder and hit Enter. Modify the way to the folder with the actual folder path.

STEP 3: Make a blank file.

Type |type nul > filename.txt

Modify filename.txt with a name according to your preference and hit Enter.

The “.txt” extension means that it’s a plain text file.

“.docx” (Word document), “.png” (empty photo), and “.rtf” (rich text document) are other popular file extensions.

All of these file formats may be viewed on any Windows system without the need for extra software.

Step 4: Make a file with certain text in it.

Replace testfile with the appropriate file name in copy con testfile.txt. Hit Enter.

Enter any text. This is a basic text editor, but it’s adequate for brief notes or coding. To move to the following line, use the Enter key.

Press Control + Z after you’re done editing the file.

Hit the Enter key. You should notice “1 file(s) copied,” meaning your file has been saved using the name you chose.

OR

|echo enter your text here > filename.txt.

STEP 5: Make a file of a specific size.

Avoid this step, if you don’t wish to deliver a document of a specific size. Utilize the accompanying order to produce a clear text document dependent on its byte size.

|fsutil file createnew filename.txt 1000

Replace filename with the name of your wish and 1000 with the exact number of bytes you want the document to be.

Other useful articles:

  • Basic Windows CMD commands
  • Cool CMD Commands Tips and Tricks
  • Best CMD Commands for Hacking
  • CMD Commands for Wireless Network Speed
  • Useful Keyboard Shortcuts for CMD
  • What Info about My Laptop Can I Check with CMD and How?
  • Getting Started with CMD Windows
  • TOP-12 Command-Line Interview Questions (Basic)
  • Command-Line Interview Questions (Advanced)
  • CMD Commands to Repair Windows
  • CMD Commands to Speed Up Computer
  • CMD Commands for MAC OS
  • How Does the Command Line Work?
  • MS-Dos Interview Questions in 2021
  • Windows OS Versions and History
  • Recent Windows Versions Compared
  • Basic Windows Prompt Commands for Every Day
  • Windows Command Line Cheat Sheet For Everyone
  • Windows Command Line Restart
  • Windows Command Line for Loop
  • Windows Command — Change Directory
  • Windows Command — Delete Directory
  • Windows Command Line – Set Environment Variable
  • How Do I Run Command Line
  • Windows Command Line Create File

on January 3, 2009

We can create files from command line in two ways. The first way is to use fsutil command and the other way is to use echo command. If you want to write any specific data in the file then use echo command. If you are not bothered about the data in the file but just want to create a file of some specific size then you can use fsutil command.

To create file using echo

echo some-text  > filename.txt

Example:

C:\>echo This is a sample text file > sample.txt
C:\>type sample.txt
This is a sample text file
C:\>

To create file using fsutil

fsutil file createnew filename number_of_bytes

Example:

C:\data>fsutil file createnew sample2.txt 2000
File C:\data\sample2.txt is created
C:\data>dir
01/23/2016  09:34 PM     2,000 sample2.txt
C:\data>

Limitations

Fsutil can be used only by administrators. For non-admin users it throws up below error.

c:\>fsutil file /?
The FSUTIL utility requires that you have administrative privileges.
c:\>

Do you need to create a file in CMD Windows 10 but don’t know where to start? This guide will provide step-by-step instructions to successfully create a file in CMD Windows 10. Read on to find out more!

Step-by-Step Tutorial to Create a File in CMD Windows 10:

  • Open the Command Prompt
  • Type ‘md’ followed by a folder name
  • Press Enter
  • Type ‘copy con’ followed by a file name
  • Press Enter
  • Type the content of the file
  • Press Ctrl+Z
  • Press Enter
  • Type ‘dir’ and press Enter
  • The file will be listed in the directory

How Do I Create A File In Windows 10?

Creating a file in Windows 10 is a simple task that can be completed in a few short steps. The first step is to open the File Explorer. This can be done by pressing the Windows Key and E at the same time, or by clicking the folder icon in the taskbar.

Once the File Explorer window is open, you will need to navigate to the location where you would like to create the file. Once you have navigated to the desired location, you will need to right-click anywhere in the window, and select ‘New’ from the drop-down menu. From here, you will then need to select which type of file you would like to create.

How To Create A File In CMD Windows 10?

You can choose to create a new text file, folder, contact, compressed (zipped) folder, or any other type of file, depending on your needs. After selecting the desired file type, the file will be created in the same location as the File Explorer window was open.

You can then begin to add content to the file, or simply save it for future use. Creating a file in Windows 10 is a simple and straightforward process, and once you have completed it a few times, you will become an expert in no time.

How To Create Empty File In CMD?

Creating an empty file in cmd (Command Prompt) is a common task for system administrators. It is also useful for users who need to create a file for a particular purpose. For example, a user may need to create a blank text file in order to store data or write a script. To create an empty file in cmd, the user must first open the cmd window. After this, they should enter the following command: «echo > {filename}». In this command, {filename} should be replaced with the desired filename.

For example, if the desired filename is «test.txt,» the command should be «echo > test.txt.» Entering this command will create an empty text file with the given filename in the same directory as the cmd window. To create an empty file with a different extension, the user should simply replace the «.txt» part of the command with the desired extension. For example, a user may wish to create an empty «.bat» file for a script. To do this, the command should be «echo > test.bat» instead.

In addition to creating empty files, cmd can also be used to create files with existing content. To do this, the user should enter the command «echo {content} > {filename}» instead. In this command, {content} should be replaced with the desired text and {filename} should be replaced with the desired filename.

For example, if the user wishes to create a file with the word «Hello» in it, they should enter the command «echo Hello > test.txt». This will create a file with the given filename and the given content inside the file.

How Do You Create A File In Windows?

Creating a file in Windows is easy to do and can be done in a few different ways. The first way is to open File Explorer, which is the default file manager app in Windows. From here, navigate to the directory you wish to create the file in, and then click the “New” button on the Home tab.

This will open a menu with the option to create a new file. Select the type of file you wish to create, give it a name, and then click “Create” to finish. Another way to create a file in Windows is by using the command line. To do this, you need to open an elevated Command Prompt window. From here, use the “mkdir” command to create a new directory, and then use the “copy” command to create a new file in the directory. You can also use the “move” command to move the file to another directory if desired.

Finally, you can also create a file in Windows by using any of the text editors installed on the system. For example, you can open Notepad and use it to create a new file. After writing the content, you can then save it in the desired directory. Similarly, you can also use Microsoft Word or any other text editor to create files.

How Can I Create File In CMD?

Creating files in Command Prompt (CMD) is an easy process, and it can be done in several ways. One way is to use the «echo» command, which is used to display a line of text. The syntax for the echo command is «echo [text] > [filename]». The text you enter as the argument for the echo command will be written to the file, and the filename will be the name of the file you create.

For example, if you wanted to create a file called «hello.txt» with the text «Hello World» in it, you would enter the following command: «echo Hello World > hello.txt». Another way to create a file in CMD is to use the «copy con» command. The syntax for this command is «copy con [filename]». This will open a text editor where you can enter the text you want to be written to the file. When you are finished entering text, press Control+Z to save the file and close the text editor.

You can also use the «type» command to create a file in CMD. The syntax for this command is «type [filename]». This will open the file in the CMD window, and you can enter the text you want to be written to the file. When you are finished entering the text, press Control+Z to save the file and close the text editor.

How To Create A Text File In CMD?

Creating a text file in CMD (Command Prompt) in Windows 10 can be done in a few simple steps.

1. Open the Start menu and type «CMD» into the search bar. Select the Command Prompt program that appears in the search results.

2. If you want to create the file in a specific directory, enter the directory path you want to use. For example, if you want to create a file in the Desktop folder, type «cd Desktop».

3. Once you are in the appropriate directory, type «type nul > Filename.txt» and press Enter. Replace «Filename» with the name of the file you want to create. For example, if you want to create a file named «MyFile», type «type nul > MyFile.txt».

4. The command prompt will create the file in the current directory. You can also verify that the file was created by typing «dir» in the directory.

5. To edit the contents of the file, type «Notepad Filename.txt» and press Enter. Replace «Filename» with the name of the text file you created. This will open the file in Notepad, allowing you to add or edit the text in the file.

6. Once you are done editing the file, save it and close Notepad.

You will now have a text file created and saved in the directory you specified.

How To Create A Text File In A Folder Using CMD?

Creating a new text file using CMD in Windows 10 is a simple process. CMD stands for Command Prompt, a command line interpreter that allows users to execute various commands in Windows.

Here are the steps to create a new text file and folder using CMD in Windows 10:

1. Open Command Prompt and type “cd\”. This will take you to the root directory of your system.

2. Now type “md \folder name” to create a folder.

3. Now type “cd folder name” to enter the folder.

4. To create a text file, type “type nul > filename.txt”

5. To write some text in the text file, type “echo text > filename.txt”

6. To view the text file, type “type filename.txt”

7. To delete the text file, type “del filename.txt”

By following these steps, you can easily create a text file and folder using CMD in Windows 10. With CMD, you can also perform various other operations such as view and delete files, copy and move files, and create and delete folders.

Touch Command In Windows

The touch command is a useful tool available in Windows 10 that allows users to create new files without the use of a text editor or other programs. This command is especially useful for creating scripts, configuration files, and other text-based documents. This tutorial will show you how to use the touch command in Windows 10. To create a file using the touch command, open the Command Prompt window and type the command followed by the name of the file you wish to create.

For example, to create a file called «example.txt» you would type «touch example.txt» into the Command Prompt window. Once the command is executed, a new file will be created in the current directory. The touch command also supports several arguments that can be used to alter the properties of the file being created.

For example, the «-a» argument can be used to set the last access time of the file, and the «-m» argument can be used to set the last modification time. Additionally, the «-c» argument can be used to suppress the creation of the file if the specified file already exists. To view the full list of available arguments, type «touch /?» into the Command Prompt window.

Create File Command Line Linux

To create a file in the command line of Windows 10, you will need to use the «echo» command. This command allows you to write text to a file by echoing it to the command line. To use this command, open the Windows command line, type «echo» followed by the text you want to write to the file and then type the name of the file you want to create.

For example, if you want to create a file called «hello.txt» with the text «Hello world!», you would type «echo Hello world! > hello.txt». This will create the file «hello.txt» and will contain the text «Hello world!». Another way to create a file in Windows 10 is to use the «type» command.

This command allows you to create a file by typing in text. To use this command, type «type» followed by the text you want to write to the file, and then type the name of the file you want to create. For example, if you want to create a file called «myfile.txt» with the text «My first file!», you would type «type My first file! > myfile.txt».

This will create the file «myfile.txt» and will contain the text «My first file!». Both of these commands are useful for creating files in Windows 10. You can use either of these command to create a file quickly and easily.

Command Line Create File Mac

Creating a new file in the command line in Windows 10 is not a difficult task. You can use the built-in command line tools to create a file quickly and efficiently. To create a new file in the command line in Windows 10, you need to open the Command Prompt window.

To open the Command Prompt window, press the Windows key + X on your keyboard, select Command Prompt (Admin) from the menu, and then type your command. The command to create a file is “type nul > filename.extension”. The “type nul” command creates a file with no content, and the “>” is used to redirect the output to a file. The “filename.extension” is the name and extension of the file that you want to create.

For example, if you want to create a file called “myfile.txt”, the command would be “type nul > myfile.txt”. Once you have entered the command and pressed Enter, the file will be created in the current directory. You can then use other command line tools to edit, rename, or delete the file. If you want to create multiple files at once, you can use the “copy con” command. This command allows you to create multiple files in one command line.

To use the “copy con” command, type “copy con filename1.extension filename2.extension filename3.extension” and then press Enter. This will create three files called “filename1.extension”, “filename2.extension”, and “filename3.extension” in the current directory.

Creating files in the command line in Windows 10 is a simple process that can be done quickly and easily. You can use the “type nul” and “copy con” commands to create files quickly and easily in the Command Prompt window.

Command To Create A File In Windows Powershell

Creating a new file in Windows Powershell is a simple task that requires only a few steps. To start, open Powershell by searching for it in the Windows search bar. Once open, you can use the New-Item command to create a file. This command requires two pieces of information: the path to the file and the name of the file. To enter the path, simply type in the folder that you wish to create the file in.

To enter the file name, just enter the name you want to give to the file. Once you have entered the necessary information, press enter and the file will be created. If you’d like to check that the file has been created, you can type in the command “Get-ChildItem” followed by the path to the file. This will display a list of all the items in the folder, including the file you just created.

To open the file, you can use the command “Invoke-Item” followed by the path to the file. Creating a file in Windows Powershell is a quick and easy task that can be accomplished with just a few steps. With the New-Item command, you can create a new file in just a few moments, allowing you to get back to work in no time.

Cmd Create Folder

Creating a new folder or file in Windows 10 using Command Prompt (CMD) is a simple task. To create a new folder, open the Command Prompt and type in the command «mkdir» followed by the name of the folder you wish to create. For example, the command «mkdir newFolder» will create a folder named «newFolder» in the directory you currently have open.

Once the folder is created, you can create a file in this folder by using the command «echo.» followed by the name of the file you wish to create and its contents. For example, the command «echo. > newFile.txt» will create a file named «newFile.txt» in the «newFolder» folder and its contents will be whatever you want to enter into the command.

To view the contents of the folder and the newly created file, type in the command «dir.» This will list all of the files and folders contained within the directory you have open. You can also use the command «type» followed by the name of the file you created to view the contents of that file.

Create Text File Command Line Linux

It is possible to create a file in Command Prompt Windows 10 using the built-in command line text editors. The two most commonly used command line text editors are nano and vi. To create a text file using either of these editors, open the Command Prompt window and type in the editor’s name followed by the name of the file that you want to create.

For example, to create a file called “myfile.txt” using nano, you would enter “nano myfile.txt” at the command prompt. This will open the nano text editor and allow you to enter the text that you’d like to save in the file. When you are finished editing the text, press the “Ctrl+X” key combination to exit the editor. You will be presented with a prompt asking you if you want to save the file. Press “Y” to save the file and then “Enter”.

The file will then be created. To create a file using vi, you would enter “vi myfile.txt” at the command prompt. This will open the vi text editor allowing you to enter the text that you’d like to save in the file. When you are finished editing the text, press the “Esc” key to enter command mode. Type “:wq” to write the file and quit the editor. The file will then be created.

Conclusion

Creating a file in CMD Windows 10 is an easy task that anyone can do with the right instructions. Knowing how to create a file in CMD Windows 10 can give you the ability to easily modify your files with the powerful options of the command line.

With just a few simple commands, you can create and customize your files with ease. By following the steps outlined in this article, you now have the necessary tools to create, edit, and customize your files in the command line. Now that you know how to create a file in CMD Windows 10, you can use this powerful tool to your advantage.

Without redirection, Luc Vu or Erik Konstantopoulos point out to:

copy NUL EMptyFile.txt
copy /b NUL EmptyFile.txt

«How to create empty text file from a batch file?» (2008) also points to:

type NUL > EmptyFile.txt
# also
echo. 2>EmptyFile.txt
copy nul file.txt > nul # also in qid's answer below
REM. > empty.file
fsutil file createnew file.cmd 0 # to create a file on a mapped drive

Nomad mentions an original one:

C:\Users\VonC\prog\tests>aaaa > empty_file
'aaaa' is not recognized as an internal or external command, operable program or batch file.

C:\Users\VonC\prog\tests>dir

 Folder C:\Users\VonC\prog\tests

27/11/2013  10:40    <REP>          .
27/11/2013  10:40    <REP>          ..
27/11/2013  10:40                 0 empty_file

In the same spirit, Samuel suggests in the comments:

the shortest one I use is basically the one by Nomad:

.>out.txt

It does give an error:

'.' is not recognized as an internal or external command

But this error is on stderr. And > only redirects stdout, where nothing have been produced.
Hence the creation of an empty file.
The error message can be disregarded here. Or, as in Rain’s answer, redirected to NUL:

.>out.txt 2>NUL

(Original answer, November 2009)

echo.>filename

(echo "" would actually put «» in the file! And echo without the ‘.’ would put «Command ECHO activated» in the file…)

Note: the resulting file is not empty but includes a return line sequence: 2 bytes.


This discussion points to a true batch solution for a real empty file:

 <nul (set/p z=) >filename

 dir filename
 11/09/2009  19:45                 0 filename
 1 file(s)                         0 bytes

The «<nul» pipes a nul response to the set/p command, which will cause the
variable used to remain unchanged. As usual with set/p, the string to the
right of the equal sign is displayed as a prompt with no CRLF.

Since here the «string to the right of the equal sign» is empty… the result is an empty file.


The difference with cd. > filename (which is mentioned in Patrick Cuff’s answer and does also produce a 0-byte-length file) is that this «bit of redirection» (the <nul... trick) can be used to echo lines without any CR:

<nul (set/p z=hello) >out.txt
<nul (set/p z= world!) >>out.txt
dir out.txt

The dir command should indicate the file size as 11 bytes: «helloworld!«.

  • Make bootable usb from iso windows 10
  • Mail ru браузер скачать бесплатно для windows 10
  • Mak ключи для windows что это
  • Magic wifi для windows 10
  • Magictune samsung скачать для windows 7 64 bit