Login | |
|
 |
RE: create a folder with subfolders - 4/3/2008 5:07:52 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
Well the first thing is to decide how the folders would be entered if their were multiple ones. Using spaces as a delimiter is not wise because space is a valid character for a folder name. This would cause trouble when parsing. I would personally use comma for the delimiter. What do you plan to use?
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: create a folder with subfolders - 4/3/2008 5:34:30 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
Ok, so you need a way to take a comma delimited string and turn that into a list that you can iterate through. The simplest list to iterate through in vbscript (and most languages) is the array. So what you need is a function that takes a string and turns it into an array. That function is Split(). Look up the documentation for Split() and you should find an example of taking a string, breaking it into parts, then doing something with each of those parts.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: create a folder with subfolders - 4/3/2008 7:18:48 AM
|
|
 |
|
| |
lazydev
Posts: 21
Score: 0
Joined: 2/21/2008
Status: offline
|
Ok .Split works fine Now how to get the count of this value . Dim strAryWords Dim strValue strValue = "This,is,the,first,VB,script,by,abcd,xyx" strAryWords = Split(strValue, ",") ' - strAryWords is now an array Dim i For i = 0 to Ubound(strAryWords) Wscript.echo i & " = " & strAryWords(i) & "" Next
|
|
| |
|
|
|
 |
RE: create a folder with subfolders - 4/3/2008 7:54:53 AM
|
|
 |
|
| |
ebgreen
Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
|
What exactly are you entering to be split? By the way it is often easier to hard code a value while you are developing rather than asking the user every time that the script runs. That way you don't have to continually enter a value every time that you test something. Also to get the user input I would change these lines: Wscript.StdOut.WriteLine " Enter your Folder Name : " strValue = Wscript.StdIn.ReadLine To this: strValue = InputBox("Enter your Folder Name") Then think further about exactly what the script is doing. You ask the user for multiple files, Let's say I put in "Foo,Bar,Weasles" when you ask me. So now: strValue = "Foo,Bar,Weasels" Then right after that you put the contents of strValue together with strRoot to get a value for sFolder so after this line executes: Dim sFolder : sFolder = strRoot & "\" & strValue then sFolder has a value of: sFolder = "D:\Archive\Active\Foo,Bar,Weasels" Then in the loop you check to see if sFolder exists. Will a folder named "D:\Archive\Active\Foo,Bar,Weasels" ever exist? Of course not. For one thing , is not valid in a folder name. That is why we chose it.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|