Is there a way of creating multiple files in Windows by using its own command prompt (cmd.exe
) or terminal emulator if you call it, just like the below simple one liner would do in any Unix-like system? Note that I'm talking about a situation where I can't use any alternative terminal emulators like PowerShell or Win 32 ports of GNU utils.
for i in `seq 10` ; do `touch $i.txt`; done
Nothing is probably easier than creating new files and folders in Windows. Just right-click in the blank space, select New and choose whatever you want to create: a File, a Folder, or even a shortcut.
Instead, you can create multiple folders at once using the Command Prompt, PowerShell, or a batch file. These apps save you from the task of right-clicking > New Folder or using Ctrl+Shift+N to make a new folder, which is tiresome if you have to make several of them.
Open the Command Prompt window. Use the cd command to go to the folder where you want to create the file. Use the below command to create a new file in Command Prompt. You can replace the dummy content with the content of your choice and the file extension can be anything.
You can use the New-Item cmdlet to create a new file with the PowerShell command-line tool. Here’s how. 1. Open the PowerShell window. 2. Use the cd command to go to the directory where you want to create the new file. 3. Execute the below command to create a new file. Replace “filename.txt” with the file name and type of your choice.
1. Open the Command Prompt window. 2. Use the cd command to go to the folder where you want to create a new file. 3. Execute the below command to create a new blank file. The file can be of any extension. 4. To create a new file with specific file size, use the below command.
Instead, you can create multiple folders at once using the Command Prompt, PowerShell, or a batch file. These apps save you from the task of right-clicking > New Folder or using Ctrl+Shift+N to make a new folder, which is tiresome if you have to make several of them. However, there are ways that you can avoid that.
for /l %a in (1 1 10) do type nul > "%a.txt"
For each value in the sequence from 1 in steps of 1 up to 10, create (>
redirection) a empty file (type nul
reads nothing and writes nothing) using the value in the sequence as filename (the value in the for
replaceable parameter)
The command is written to be used from command line. Inside a batch file percent signs need to be escaped (doubling them), replacing %a
with %%a
Use windows syntax:
for %A in (1 2 3) do type nul > file%A.txt
or
for %A in (1 2 3) do echo.> file%A.txt
or
for %A in (1 2 3) do copy nul > file%A.txt
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