Help needed for creating Folder structure
Moderator: DosItHelp
-
- Posts: 14
- Joined: 16 Jan 2012 04:56
Help needed for creating Folder structure
I guess this might seem pretty noobish to ask.I am a completely new to programming.I need help for a little .bat script which I made.
Colors>red
>blue
>green
>orange
>and more
Right now what I do is go to every folder and run the script.
I want a script which will create folder structure inside all the folders.
Right now I am using this
if not exist "1\" (
md 1
md 1\a
md 1\b
md 1\c
)
Colors>red
>blue
>green
>orange
>and more
Right now what I do is go to every folder and run the script.
I want a script which will create folder structure inside all the folders.
Right now I am using this
if not exist "1\" (
md 1
md 1\a
md 1\b
md 1\c
)
Re: Help needed for creating Folder structure
Are you saying you have this folder structure
And you want a script to make a series of sub folders named 1\a 1\b and 1\c inside each of them to look like this?
Code: Select all
E:\>tree colors
Folder PATH listing for volume Big Drive
Volume serial number is D23A-41A4
E:\COLORS
├───blue
├───green
├───oragne
└───red
And you want a script to make a series of sub folders named 1\a 1\b and 1\c inside each of them to look like this?
Code: Select all
E:\>tree colors
Folder PATH listing for volume Big Drive
Volume serial number is D23A-41A4
E:\COLORS
├───blue
│ └───1
│ ├───a
│ ├───b
│ └───c
├───green
│ └───1
│ ├───a
│ ├───b
│ └───c
├───oragne
│ └───1
│ ├───a
│ ├───b
│ └───c
└───red
└───1
├───a
├───b
└───c
-
- Posts: 14
- Joined: 16 Jan 2012 04:56
Re: Help needed for creating Folder structure
@Squashman
yes exactly...
**sorry for my poor explanation..
yes exactly...
**sorry for my poor explanation..
Re: Help needed for creating Folder structure
Code: Select all
for /d %%i in ("E:\COLORS\*") do (
md "%%i\1\a"
md "%%i\1\b"
md "%%i\1\c"
)
It doesn't matter if one of the folders already exists. It will not be overwritten, all you get is an error message in this case.
Regards
aGerman
Re: Help needed for creating Folder structure
aGerman wrote: md "%%i\1\a"
md "%%i\1\b"
md "%%i\1\c"
Code: Select all
md "%%i\1\a" "%%i\1\b" "%%i\1\c" 2>nul
Re: Help needed for creating Folder structure

That's undocumented. I wasn't aware this could work. Awesome

Regards
aGerman
Re: Help needed for creating Folder structure
'
Never seen that before
!k++
Never seen that before

-
- Posts: 14
- Joined: 16 Jan 2012 04:56
Re: Help needed for creating Folder structure
Thanks a lot !k and aGerman..
-
- Posts: 14
- Joined: 16 Jan 2012 04:56
Re: Help needed for creating Folder structure
The following is the folder structure I need.
E:\COLORS
├───scriptfile
│ createfolders.bat
├───green
│ └───1
│ ├───a
│ ├───b
│ └───c
├───oragne
│ └───1
│ ├───a
│ ├───b
│ └───c
Since I wanted the batch file to create folders in current directory.I modified it to this
SET "CDIR=%~dp0"
for /d %%i in ("%CDIR%\..\*") do (
md "%%i\1\a"
md "%%i\1\b"
md "%%i\1\c"
)
The problem is when createfolders.bat is executed , it creates the folder structure in all the folders including its parent folder.
Is it possible to exclude its parent folder/a particular folder ; and to create folder structure in the rest
E:\COLORS
├───scriptfile
│ createfolders.bat
├───green
│ └───1
│ ├───a
│ ├───b
│ └───c
├───oragne
│ └───1
│ ├───a
│ ├───b
│ └───c
Since I wanted the batch file to create folders in current directory.I modified it to this
SET "CDIR=%~dp0"
for /d %%i in ("%CDIR%\..\*") do (
md "%%i\1\a"
md "%%i\1\b"
md "%%i\1\c"
)
The problem is when createfolders.bat is executed , it creates the folder structure in all the folders including its parent folder.
Is it possible to exclude its parent folder/a particular folder ; and to create folder structure in the rest