I need an automatic way of making a lot of numbered folders
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Droplet of life
--
Chapters
00:00 I Need An Automatic Way Of Making A Lot Of Numbered Folders
00:39 Accepted Answer Score 50
01:09 Answer 2 Score 37
01:39 Answer 3 Score 14
02:09 Answer 4 Score 8
02:57 Answer 5 Score 8
03:12 Thank you
--
Full question
https://superuser.com/questions/1490223/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows10 #filemanagement #numbering #fileorganization
#avk47
ACCEPTED ANSWER
Score 50
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 (
ANSWER 2
Score 37
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
.
ANSWER 3
Score 14
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.
ANSWER 4
Score 8
The free Total Commander can create multiple folders with one command since version 9.10 (2017).
Press F7 to open the Create Directory dialog, then enter
<1-99>ch.[C:3]
as shown below, and it will create the folders you need.
The complete syntax is as follows, with begin
, step
and width
being optional:
<(counterstart)-(counterend)>sometext[C(begin)(+-)(step):(width)]sometext
Previous answer:
It also has a GUI for renaming things, useful if you already have the right number of directories but with wrong names (such as by copy-pasting lots of empty dirs).
Select the folders and open Files -> Multi-Rename Tool. The image shows settings that rename all folders to the scheme you want.
ANSWER 5
Score 8
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))