≡ Menu

Create empty file

In Linux, we can create an empty file using ‘touch‘ command. There’s no equivalent command for touch in Windows OS. However, we can still create zero byte files using  the command fsutil.

The syntax of fsutil command for creating a file is:

fsutil file createnew filename  requiredSize

Below is the command you can run to create a empty text file.

fsutil file createnew filename 0

Example:

C:\>fsutil file createnew emptyfile.txt 0
File C:\emptyfile.txt is created

C:\>dir emptyfile.txt
02/06/2012  10:50 PM                 0 emptyfile.txt
 C:\>

The above command can be run from a batch file also. It works on all Windows editions: XP, Server 2003, Vista, Windows 7, Server 2008.

fsutil‘ command should be run from elevated administrator command prompt. Otherwise, you would get the below error message.

c:\>fsutil file createnew emptyfile.txt 0
The FSUTIL utility requires that you have administrative privileges.

Using echo command

In Linux, we can use echo command also to create empty text files. This command is available in Windows also.
But using ‘echo’ we can’t create empty files. See below.

c:\> echo > newfile.txt
c:\>
c:\>dir newfile.txt
02/06/2012  10:47 PM                13 newfile.txt
c:\>

As you can see, it has created a file of size 13 bytes.

Related Posts:

5 comments… add one
  • Ali

    Hi

    We can use the “TYPE” command also to create an empty file in Windows from the CMD, and it doesn’t require the administrative privileges unlike the fsutil command. below is the command you can run to create an empty file. (for example: empty.txt)

    C:\>type nul > empty.txt

  • Ronald

    hello,

    your explaining is very helpful. but how to create file names with spaces in them?
    thanks!

  • admin

    You need to wrap the file name in double quotes. For example

    C:\> echo somedata > "file with spaces.txt"
    C:\>more "file with spaces.txt"
    somedata
  • Cita

    In dos we were using basic command copy with con argument, and something like EOF from unix. : )

    C:\>copy config.sys + con
    config.sys
    con
    shell=c:\command.com c:\ /p /e:512
    ^z

  • Guy

    how do you now put data on the file like insted of it empty have it create a txt file with hello in it ????

Leave a Comment