I need an automatic way of making a lot of numbered folders

I need 100 or more folders named like such: ch.000, ch.001, ch.002, etc. In this case I need it to go up to ch.094 but I will need to create more folders later. That may be more or less folders, but definitely between 000 and 999. I don't know anything about programming, so please guide me through it.

Here is an example of what I need to do.

Screenshot of folders ch.000 to ch.012

Thank You!


Create a .bat file inside the folder in which to create these sub-folders, and copy inside the following text:

@echo off
setlocal enableDelayedExpansion
FOR /l %%N in (1,1,94) do (
    set "NUM=00%%N"
    set "DIRNAME=ch.!NUM:~-3!"
    md !DIRNAME!
)

Double-click the .bat file and it will create the required chapters.

In the future, if you wish to create for example numbers 95 to 110, just change the FOR line to:

FOR /l %%N in (95,1,110) do (

Here's a PowerShell script:

for ($i=1; $i -lt 95; $i++) {
  $name = [string]::Format("ch.{0}", $i.ToString("000"));
  New-Item -Path "c:\source\temp" -Name $name -ItemType "directory"
}

Assuming you're on Windows, you can do Start > Run > "powershell.exe" > OK, then copy/paste this to the command line.

Note that you'll want to change c:\source\temp to the directory where you want the folders, and you can adjust the range to be created by adjusting the values in the for statement, where you see 1 and 95.


I believe there now is a Linux subsustem in Windows (I've never used it - in fact, I don't use Windows at all), so you could use a bash script - type it on the command line in a bash shell (is that the term in windows? - and note that '$' is the bash-prompt):

$ for i in $(seq -w 1 100)
> do
> mkdir ch.$i
> done

Personally I think it looks better than the powershell version - not least because you can split commands that take a block, over several lines.


If you can run Linux commands on Windows, the most succinct way would probably be:

mkdir ch.{000..099}

If that doesn't work (because you use ksh or otherwise), then this should work:

mkdir $(printf 'ch.%s\n' $(seq -w 000 099))