Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 11th, 2006, 01:44 PM
Authorized User
 
Join Date: Dec 2005
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
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





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





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