Create file from command line

We can create files from command line in two ways. The first way is to use fsutilcommand 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


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

To create file using fsutil

fsutil file createnew filename number_of_bytes


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


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.