How can I can create all these sub-folders at once, using my naming scheme?
If I were to create the sub-folders in a specific directory, such as C:\Dropbox\Development, would I need to cd to that directory first? Assuming I'm using the cmd shell?
To create the sub-folders (sub-directories) in a specific directory (that is not the current directory), you can do one of the following:
cd C:\Dropbox\Development
first or
- Change the
md Lec-%%i
command to md C:\Dropbox\Development\Lec-%%i
.
Note:
mkdir
is a synonym for md
and can be used in its place.
Below I show both alternatives, first from a cmd
shell (command line), and second using a batch file.
As a bonus (although not asked for in the original question) there is a bash
shell alternative as well.
From a cmd
shell:
cd C:\Dropbox\Development
for /l %i in (9,1,120) do md Lec-%i
or
for /l %i in (9,1,120) do md C:\Dropbox\Development\Lec-%i
From a batch file:
@echo off
cd C:\Dropbox\Development
for /l %%i in (9,1,120) do md Lec-%%i
Or
@echo off
for /l %%i in (9,1,120) do md C:\Dropbox\Development\Lec-%%i
Notes:
Is there a way to do a similar thing for Mac OSX from the Mac terminal?
From a bash
shell:
for i in {9..120}; do mkdir Lec-$i; done;
Or (for a more portable version)
for i in `seq 9 120`; do mkdir Lec-$i; done;
Further Reading