Script to prompt for folder name and create folder structure

I have a handy tool from a departed support tech. The exe, when executed, prompts for 'Project number and Name'. When entered and the person hits OK, a folder is created wherever you executed the exe along with a designated sub folder structure. Example below:

123 Big Job
  \Accounting
       \Receipts
       \Contract
  \Drawings
       \Proposal
            \Design CAD
        \Marketing
  \Project Management
        \Contract
               \Bids
         \Final Contract

You get the idea. How is this done and how was it zipped to an EXE?

Obviously, my 15 years in IT has not had me do any scripting, I've always had a staff programmer but budget cuts eliminated that.

exe file available upon request
.
LVL 3
BrandonProject Manager, IT Systems and Software DesignAsked:
Who is Participating?
 
Bill PrewCommented:
Hard to say what language the EXE was done in, but my guess is whatever it was, it just created folders under the project number and name.  This could easily be done with a simple batch script if that was helpful?

@echo off
:PromptLoop
set ProjectNumber=
set ProjectName=
set /P "ProjectNumber=Please enter the project number: "
set /P "ProjectName=Please enter the project name: "
if "%ProjectNumber%" EQU "" (
  echo No project number entered, try again.
  goto :PromptLoop
)
if "%ProjectName%" EQU "" (
  echo No project name entered, try again.
  goto :PromptLoop
)
md "%ProjectNumber% %ProjectName%"
md "%ProjectNumber% %ProjectName%\Accounting"
md "%ProjectNumber% %ProjectName%\Accounting\Receipts"
md "%ProjectNumber% %ProjectName%\Accounting\Contract"
md "%ProjectNumber% %ProjectName%\Drawings"
md "%ProjectNumber% %ProjectName%\Drawings\Proposal"
md "%ProjectNumber% %ProjectName%\Drawings\Proposal\Design CAD"
md "%ProjectNumber% %ProjectName%\Drawings\Marketing"
md "%ProjectNumber% %ProjectName%\Project Management"
md "%ProjectNumber% %ProjectName%\Project Management\Contract"
md "%ProjectNumber% %ProjectName%\Project Management\Contract\Bids"
md "%ProjectNumber% %ProjectName%\Project Management\Final Contract"
tree "%ProjectNumber% %ProjectName%"

Open in new window

~bp
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Great script bp, depending the OS that is used, the md commands can be written down a bit shorter:

md "%ProjectNumber% %ProjectName%\Accounting\Receipts"
md "%ProjectNumber% %ProjectName%\Accounting\Contract"
md "%ProjectNumber% %ProjectName%\Drawings\Proposal\Design CAD"
md "%ProjectNumber% %ProjectName%\Drawings\Marketing"
md "%ProjectNumber% %ProjectName%\Project Management\Contract\Bids"
md "%ProjectNumber% %ProjectName%\Project Management\Final Contract"

Windows7 makedir:

MKDIR creates any intermediate directories in the path, if needed.
0
 
Bill PrewCommented:
@gerwinjansen

Yes, I've always liked the fact that MD creates all needed intermediate directories (unlike VBS I believe), but in this case for potential future maintenance I decide it was more clear to list every level.  Like if in the future he didn't need:

md "%ProjectNumber% %ProjectName%\Drawings\Proposal\Design CAD"

but still needed:

md "%ProjectNumber% %ProjectName%\Drawings\Proposal"

I figured less chance of confusion listing then explicitly.  Make sense?

~bp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Gerwin Jansen, EE MVETopic Advisor Commented:
Yes, makes perfect sense :)
0
 
BrandonProject Manager, IT Systems and Software DesignAuthor Commented:
Great script, worked perfectly. The current program prompts for the info in a nice need windows type of outline instead of a cmd line. But I'm guessing they used some type of exe creating tool that did that. Found a great exe tool that simply compiled the data and added an icon image along with version data.

Thanks again, I'll make it fansy later when I actually have time.
0
 
Bill PrewCommented:
Glad that helped, thanks for the feedback.

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.