batch-file

How to create multiple text files with different names using batch?


I am fairly new to any programming.
I have a task to perform in which the requirement is detailed below:

  1. There should be created 65536 text files.
  2. Each file must have a name starting from 1.txt to 65536.txt.
  3. Each file will have a certain text in it, in which at a particular place the file name must appear. For example, the existing text looks like DIAGRAM VARIABLE 0 0 1098 5 6. The number 1098 in this text must be the number in file name.

Solution

  • You can try this (havent tested) for /l iterates %%x from 1 to 65536 and then echo writes whats left of the > to the filename specified to the right.

    for /l %%x in (1, 1, 6 ) do (
     echo STRING TO BE WRITTEN NO %%x > %%x.txt
    )