Batch command to create blank text files

This might be a rather unique requirement: I need to generate a vast number of empty text files. In the Windows operating system, I typically use the right-click menu to create a new text document and then rely on the copy-paste shortcuts for replication. While creating 10 files is straightforward, what about 100, 1,000, or even more? Actually, we can employ the Batch command to expedite the creation of numerous empty text files. This Batch command will create blank text files in the current directory.
rem This batch command will create blank text files in the current directory.
@echo off 
for /L %%x in (1,1,10) do @echo %%x>%%x.txt
This command will create 10 blank text files, named 1.txt, 2.txt, ..., 10.txt. The for loop will iterate from 1 to 10, and for each iteration, it will create a new text file with the current iteration number as the filename. The echo. command will create a blank line in the text file.

Here is an explanation of the Batch command:

  • rem is a comment that will be ignored by the command interpreter.
  • for /L %%x in (1, 1, 10) do ( is the start of a for loop. The for loop will iterate from 1 to 10, and for each iteration, it will execute the commands inside the parentheses.
  • echo. > %%x>%%x.txt is the command that will be executed for each iteration. The echo. command will create a blank line in the text file.
Batch Script – Commands Batch Command Post Lists
Batch command to Generate Text Files Based on Lines from a Source File

Batch command to extract the filenames in the current directory

Batch command to create blank text files

Batch rename files using the parent directory name

Comments

Popular posts from this blog

Installing Python3.10.x Version on Mac and Set the Environment

Adding Specific Applications to Windows 11 Startup Apps

HTTPS(SSL) Blocks WordPress Admin Access