Categories: Files

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.

Srini

View Comments

  • 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

    • People seem to be ignoring an old bug in Windows that still exists, fortunately:
      The command: echo 2> filename.txt
      will create zero-byte " filename.txt "
      and
      the command echo 2> "file name.txt"
      will create zerobyte file: " file name.txt "

      check it out

  • 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
  • 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

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

Share
Published by
Srini

Recent Posts

Add new user account from command line (CMD)

Adding users from command line is much easier than going through the UI. It saves…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows command prompt(CMD)? This post explains how…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago

How to check if Windows 32 or 64 bit?

There are multiple ways to check whether a Windows computer is running 32-bit OS or…

7 years ago