Create empty file

by admin on February 6, 2012

In Linux, we can create an empty file using ‘touch‘ command. There’s no matching equivalent command for touch in Windows OS. However, we can still create empty text files. We can use the file system configuration command ‘fsutil‘ for this purpose.

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:

{ 0 comments… add one now }

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: