Create file from command line

by admin on January 3, 2009

We can create files from command line in two ways. One is using 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 using which you can write the data directly to the file from command line. 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 text-to-be-written-into-the-file  > 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 command:

fsutil file createnew

example:

C:\data>fsutil file createnew sample2.txt 2000
File C:\data\sample2.txt is created

C:\data>dir

01/23/2009  09:34 PM             2,000 sample2.txt
C:\data>

Leave a Comment

Previous post:

Next post: