-1

I am trying to create multiple empty files to my project from the command prompt(Windows) and I always used the touch command. but what can I use if I want to create more files in the same line.

Thanks a lot!

  • 4
    Does this answer your question? [How to create an empty file at the command line in Windows?](https://stackoverflow.com/questions/1702762/how-to-create-an-empty-file-at-the-command-line-in-windows) – dan1st Mar 13 '20 at 21:25
  • @dan1st - The answer indicated as duplicate only addresses how to create one (1) empty file. The OP wants to create many. – lit Mar 14 '20 at 07:28

2 Answers2

2

You can use the FOR command like this:

FOR %N IN (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) DO (echo null > C:\temp\%N.txt)

This will create 26 empty .txt files with one line.

If you want to clean up the files created, use this:

FOR %N IN (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) DO (del C:\temp\%N.txt)

sippybear
  • 206
  • 2
  • 5
1

A FOR loop will allow you to make as many files as you want. The following command creates ten (10) files.

FOR /L %A IN(1,1,10) DO (TYPE>"%TEMP%\%~A.txt" NUL)

If this is used in a .bat file script, be sure to double the % character on the variable.

FOR /L %%A IN(1,1,10) DO (TYPE>"%TEMP%\%%~A.txt" NUL)
lit
  • 10,936
  • 7
  • 49
  • 80