Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / How can I create an empty file at the command line in Windows?

How can I create an empty file at the command line in Windows?

August 20, 2021 by James Palmer

Without redirection, Luc Vu or Erik Konstantopoulos point out to:
copy NUL EMptyFile.txt
copy /b NUL EmptyFile.txt

“How to create empty text file from a batch file?” (2008) also points to:
type NUL > EmptyFile.txt
# also
echo. 2>EmptyFile.txt
copy nul file.txt > nul # also in qid’s answer below
REM. > empty.file
fsutil file createnew file.cmd 0 # to create a file on a mapped drive

Nomad mentions an original one:
C:UsersVonCprogtests>aaaa > empty_file
‘aaaa’ is not recognized as an internal or external command, operable program or batch file.

C:UsersVonCprogtests>dir

Folder C:UsersVonCprogtests

27/11/2013 10:40 .
27/11/2013 10:40 ..
27/11/2013 10:40 0 empty_file

In the same spirit, Samuel suggests in the comments:

the shortest one I use is basically the one by Nomad:

.>out.txt

It does give an error:
‘.’ is not recognized as an internal or external command

But this error is on stderr. And > only redirects stdout, where nothing have been produced.
Hence the creation of an empty file.
The error message can be disregarded here. Or, as in Rain’s answer, redirected to NUL:
.>out.txt 2>NUL

(Original answer, November 2009)
echo.>filename

(echo “” would actually put “” in the file! And echo without the ‘.’ would put “Command ECHO activated” in the file…)
Note: the resulting file is not empty but includes a return line sequence: 2 bytes.

This discussion points to a true batch solution for a real empty file:
filename

dir filename
11/09/2009 19:45 0 filename
1 file(s) 0 bytes

The “ filename (which is mentioned in Patrick Cuff’s answer and does also produce a 0-byte-length file) is that this “bit of redirection” (the out.txt
>out.txt
dir out.txt

The dir command should indicate the file size as 11 bytes: “helloworld!”.

Try this:
type NUL > 1.txt

this will definitely create an empty file.

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in