VBScript to creat folders with sub folders

Joined
Nov 12, 2008
Messages
1
Reaction score
0
VBScript HELP!!!!!!!!!
Here is what I need to do . I need an input box to appear asking for the customer name. Once the customer name has been put in I need another input box to appear asking for the Job number. I need the script to create two sub folders and each of the two subfolders need three sub folders called . So end result it should create a file structure like this

Customer name----
------------------ Job Number---
-------------------------------- Art
------------------------------------ OriginlArt
------------------------------------ ArtUsed
------------------------------------ QuarkProofs

-------------------------------- Data
------------------------------------ RawData
------------------------------------ ProductionData
------------------------------------ DataProofs


I have been successful at parts of this but have been unable to create a script that would do everything I want it to do. Any help would be greatly appreciated. I am really new to VBScript.

I have come up with this

strRoot="C:\"
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder(strRoot)
Set colFolders=objFolder.SubFolders
strFolder = InputBox("Please Enter the FolderName.")
If objFSO.FolderExists(strRoot & strFolder) Then
WScript.Echo "Folder " & strRoot & strFolder &_
"\" & item & " already exists"
Else
colFolders.Add strFolder
End If
Wscript.Echo " " & objFolder & ""
Set objFolder=objFSO.GetFolder(strRoot \ strFolder)
Wscript.Echo " " & objFolder & ""
Set colFolders=objFolder.SubFolders
arrFolders=Array("Art","Data")
For Each item In arrFolders
If objFSO.FolderExists(strRoot & strFolder & "\" & item) Then
WScript.Echo "Folder " & strRoot & strFolder &_
"\" & item & " already exists"
Else
colFolders.Add item
End If
NEXT

which will create the directory. but if it already exist I need it to fail and say "Directory already exist" and then promt them to enter the Job Number. It does not do that. And it is not creating the sub folders the way I need it to .





I got it to work this way with a .bat file but I would really like to pretty it up with VB

cd\
SET /P cname=[Customer Name]
MKDIR C:\%cname%
SET /P pname=[Job #]
MKDIR C:\%cname%\%pname%
mkdir C:\%cname%\%pname%\ART
mkdir C:\%cname%\%pname%\DATA
cd ART
mkdir C:\%cname%\%pname%\\ART\OriginalArt
mkdir C:\%cname%\%pname%\\ART\ArtUsed
mkdir C:\%cname%\%pname%\\ART\QuarkProofs
mkdir C:\%cname%\%pname%\\ART\PDFProofs
cd..
cd data
mkdir C:\%cname%\%pname%\\DATA\OriginalData
mkdir C:\%cname%\%pname%\DATA\ProductionData
mkdir C:\%cname%\%pname%\DATA\DataProofs
cd..
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top