From this answer I can create multiple files a.txt, b.txt, ... , z.txt. in Bash with:
touch {a..z}.txt
Or 152 with:
touch {{a..z},{A..Z},{0..99}}.txt
How can I do this in Powershell?
I know New-Item a.txt, but If I want multiple files as above?
For curiosity, what are the equivalent commands in Command Prompt (cmd.exe)?
For Powershell:
1..5 | foreach { new-item -path c:\temp\$_.txt }
The foreach loop will run for each number in 1 to 5, and generate a file in the desired path with the name of that number passed to the command (represented by the $_)
You could also write it as:
%{1..5} | new-item c:\temp\$_.txt
For cmd:
for /L %v in (1,1,5) do type nul > %v.txt
More information here: cmd/batch looping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With