Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 11th, 2006, 01:44 PM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create Folder

What I want is a quick script that will ask the user for a folder range. Lets say 58 - 78. What I'm getting is 00058, 000581, 000582 ... 00060, 000601 and so on. Could you give me an idea of what I'm doing wrong?

Dim Result1, Result2, x, Folder

Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Result1 = InputBox("Enter Begining Folder Number : ")
    Msgbox "Result1 equals " & Result1
    If Result1 = "" Then
        Wscript.Echo "No input was given"
        Result1 = InputBox("Enter Begining Folder Number : ")
    End If


    Result2 = InputBox("Enter Ending Folder Number : ")
    Msgbox "Result2 equals " & Result2
    If Result2 = "" Then
        Wscript.Echo "No input was given"
        Result2 = InputBox("Enter Ending Folder Number : ")
    End If

If Result1 > Result2 Then
    MsgBox "First number can't be greater than second number"
    Wscript.Quit()
Else
    x = Result1

    While x < Result2
        Folder = ""
        Folder = "000" & x
        Set objFolder = objFSO.CreateFolder("C:\Documents and Settings\jayers\Desktop\New Folder (2)\" & Folder)
        x = x + 1
    Wend
    MsgBox "Folders Created"
End If
MsgBox " x equals " & x
WScript.Quit()

Reply With Quote
  #2 (permalink)  
Old October 11th, 2006, 02:40 PM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind I got it. Here is the code if anyone is interested.

Dim Result1, Result2, x
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

Result1 = InputBox("Enter Begining Folder Number : ")

If Result1 = "" Then
   Wscript.Echo "No input was given"
   Result1 = InputBox("Enter Begining Folder Number : ")
End If

x = Result1

Result2 = InputBox("Enter Ending Folder Number : ")

If Result2 = "" Then
   Wscript.Echo "No input was given"
   Result2 = InputBox("Enter Ending Folder Number : ")
End If

If Result1 > Result2 Then
   MsgBox "First number can't be greater than second number"
   Wscript.Quit()
Else
   For x = x to Result2 Step 1
    If objFSO.FolderExists("C:\YourStuff\" & "000" & x) Then
       Msgbox "Folder " & "000" & x & " already exists"
    else
       Set objFolder = objFSO.CreateFolder("C:\YourStuff\" & "000" & x)
       MsgBox "This folder was created " & "000" & x
    End If
   Next

End If

WScript.Quit()


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create folder abaso.jadhav01 ASP.NET 1.0 and 1.1 Basics 0 October 27th, 2006 09:25 AM
How to Create new folder(directory) in Srever ? Raam ASP.NET 2.0 Professional 1 May 10th, 2006 12:48 PM
How to create a folder in server and rename files pramos.21d ASP.NET 2.0 Basics 0 April 24th, 2006 05:27 AM
How can i create a folder? chipset VB How-To 2 July 28th, 2004 05:53 AM



All times are GMT -4. The time now is 08:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.