Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Script to prompt for folder name and create folder structure

Posted on 2011-10-28
6
Medium Priority
?
431 Views
Last Modified: 2012-05-12
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
.
0
Comment
Question by:Brandon
  • 3
  • 2
6 Comments
 
LVL 59

Accepted Solution

by:
Bill Prew earned 1300 total points
ID: 37046220
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
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 37050937
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
 
LVL 59

Expert Comment

by:Bill Prew
ID: 37050976
@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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 37050994
Yes, makes perfect sense :)
0
 
LVL 3

Author Closing Comment

by:Brandon
ID: 37053014
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
 
LVL 59

Expert Comment

by:Bill Prew
ID: 37053077
Glad that helped, thanks for the feedback.

~bp
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Starting up a Project

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question