What does "type nul > somefile" do to "somefile" in Windows?

What does “type nul > somefile” do to “somefile” in Windows?

  1. First, somefile is opened for writing – this automatically causes the file to be truncated to 0 bytes. The data still remains on disk, just marked as "free" in the bitmap

  2. Then the contents of nul are written to somefile – in this case, exactly zero bytes, since you cannot read anything from nul. The old data is not overwritten.

  3. The file is closed.

I saw a batch script website recommend generating an FTP script on the fly and then "securely" erasing it with the command in title. Is there any merit to this?

It's not any more "secure" than del somefile. It doesn't even remove the data from disk.

To erase a file securely, use a wipe utility such as sdelete or Eraser. Although, is a FTP script actually worth secure-wiping?


It 'might' overwrite the file with zeros, but even if it did, that's hardly a secure erase. You would be better off using SDelete for this if you can.


Deleting a file will not prevent third party utilities from un-deleting it again, however you can turn any file into a zero-byte file to destroy the file allocation chain like this:

TYPE nul > C:\examples\MyFile.txt

DEL C:\examples\MyFile.txt

Source half way down the page