Empty File
Here in this example I am going to show you how to create empty files in Windows system using command line tool. This will reduce your manual efforts for creating empty files for a corresponding list of files in a directory.
When there is a requirement for processing a list of files from a folder or directory and this requires that you need to have empty files for the corresponding files and without those empty files your corresponding files will not be processed from a particular directory, in such scenario you need to create empty files. And it is always better to run a command for creating so many empty files instead of creating them manually.
To create an empty file in Windows using command line tool you can use the command format echo .> filename.extension
. So to create an empty test.txt file, you can execute the command echo .> test.txt
.
Related Post:
Print Names of Files
If you need to know what all files are available in a particular directory or folder, you can use the following command to display the names of a directory using the command line tool (CLI).
for /r %i in (*) do echo %i
The above command will display all files with their full path in the command line tool.
Create Empty Files
I have shown above how to display files from a particular folder using the loop. Here in the similar way I will loop through all files in a particular directory and create empty files for the corresponding files available in the directory.
for /r %i in (*) do echo .> %i.extension
The above command you generally need to execute in a directory where you want to create empty files for a list of files.
Hope you got an idea how to create empty files in Windows environment.