Iterate over the files in the folder:
for %x in (*) do ...
Create empty files:
type NUL > %~nx.txt
The %~nx
evaluates to the file name without the extension of the loop variable %x
. So, combined:
for %x in (*) do type NUL > %~nx.txt
You could also use copy NUL %~nx.txt
but that will output 1 file(s) copied
and throw errors if the text file already exists; this is the more silent variant (or use copy /Y NUL %~nx.txt >NUL 2>&1
).
In a batch file you need to double the %
but you won't need a batch file just for this one-liner (except it's part of a larger program):
for %%x in (*) do type NUL > %%~nx.txt