Create a new file at the command line

As far as I know, Windows lacks a utility like Unix’s touch to create a new empty file from the command line.

However, you can use the copy utility to perform the same function, by copying from the NUL device to a new file :

copy NUL EmptyFile.txt

This should produce output indicating success:

1 file(s) copied.

You can confirm the file now exists and is empty by inspecting the output of the dir utility. Use the following command to inspect the file:

dir EmptyFile.txt

The output confirms that the file was recently created (relative to the time of writing), and that it is zero bytes long:

 Volume in drive C has no label.
 Volume Serial Number is 9ACB-79DF

 Directory of C:UsersSco

01/07/2012  20:43                 0 EmptyFile.txt
               1 File(s)              0 bytes
               0 Dir(s)  32,823,578,624 bytes free

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s