Windows 7 (script): Create pre-defined folder structure

6,448

Try this bat file (paste the code into notepad and save as a .bat file). The first line is a variable so change it to the root folder you want all to be created.

set rootDirectory = C:\Documents and Settings\username\Desktop\
cd %rootDirectory%
md test
md test\01

The above creates 1 folder on the desktop (called test) and then a subfolder called 01.

EDIT

In fact you don't even need the variable in this instance either (this does exactly the same, just with 1 line less code):

cd C:\Documents and Settings\username\Desktop\
md test
md test\01
Share:
6,448

Related videos on Youtube

Mestika
Author by

Mestika

Updated on September 18, 2022

Comments

  • Mestika
    Mestika over 1 year

    Is it possible to create a script, which can be activated through the right-click menu in Windows, which will create a pre-defined folder structure?
    Every time we get a new update at my work I have to make a new “update-record” inside a folder. Each update-folder contains exactly the same folders, more or less.

    I could create an empty folder structure which I could copy each time but we’re using an older CSV repository and new folders and files have to be created because of some strange reference or ID that it gives it and has trouble separating multiple copies of folders or files.
    Another issue is that my Work Laptop is “admin restricted” so I don’t have permissions to install any program, but I can run scripts (just not powershell, unfortunately, because it is not activated) and Macros.

    I’m not sure if it is possible at all but it would be a real time-saver just to create a new folder structure with a click of a button.

    Cheers,
    - Mestika

    • Dave
      Dave over 11 years
      Not a direct answer but the fact you've written vbs makes me think you can write vbs so you may be able to do VB? If so, creating a .NET solution for this would be really easy - you can also run it as a stand alone app meaning you don't need to install it.
  • Mestika
    Mestika over 11 years
    Works perfect - thanks.. I just got one follow-up question. Is there anyway to set the RootDirectory to my current Directory / path??
  • Mestika
    Mestika over 11 years
    Just figure it out :-) Thanks again
  • Dave
    Dave over 11 years
    I'm glad it worked for you.