Batch Folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 1
Joined: 17 Jul 2018 09:24

Batch Folders

#1 Post by spookjaar » 17 Jul 2018 09:37


I work for an architectural practice I have begun working with Batch Files to create our folder structure for when I new jobs arrives.

We have been working with the following;

@echo off

set /p id="Enter Project Name: " %=%
md "%id%"
md "%id%"\existing
md "%id%"\existing\models
md "%id%"\existing\drawings
md etc...

This seems to be working great to sit on the server for someone to run and create a simple folder structure.

My question is, due to the work we are doing is there anyway to do the following.

\\server\projects\level 0\"%id%"
\\server\projects\level 1\"%id%"
\\server\projects\level 2\"%id%"

Is there anyway to have the batch file in the projects folder then once the batch file is ran, a prompt appears asking which folder the directory wants to be created in, 0, 1 or 2 then once "2" has been entered for example the folder directory is then created in the level 2 directory. Rather than having 3 different .bat files in each level. I thought a simple "if" and "then" statement would work but I am unsure how these work within DOS.

This way we can understand which levels the different projects require.

Hope this makes sense, if not just ask for more information.

Posts: 84
Joined: 19 Jul 2015 02:27
Location: Philippines

Re: Batch Folders

#2 Post by Meerkat » 18 Jul 2018 08:41

See the code (I dont know how to properly start this reply!). The rem commands are comments for understanding the code, so you can remove them.

I assume that this batch file is on the "projects" folder.

Code: Select all

@echo off

set /p "id=Enter Project Name: "
rem New code...
set /p "lev=Level: "
rem Input Filter. If input less than 0, goto newcode to insist another input.
if %lev% lss 0 goto newcode
rem Also, if input greater than 2, goto newcode to insist another input.
if %lev% gtr 2 goto newcode
rem So, the valid numbers are 0,1, and 2. Now, create folders...
md "level %lev%\%id%"
md "level %lev%\%id%\existing"
md "level %lev%\%id%\existing\models"
md "level %lev%\%id%\existing\drawings"
To learn the details about the IF command, you can type help if in the command prompt.
If I misunderstood something, pls reply. :)


Post Reply