Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking vbscript code that creates a folder name from an input box 1

Status
Not open for further replies.

kdjonesmtb2

Technical User
Nov 19, 2012
93
US
Looking for vbscript code that creates a new folder from the input name entered in an input box

This code works but it creates a file not a file folder


Dim Input4

Input4 = InputBox("Enter Archive Folder Name")
MsgBox ("You entered: " & Input4)


If row=1 then

Function CreateArchiveFolder
Dim fso, f
CreateObject("Scripting.FileSystemObject")
Set fso =fso.CreateFolder("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834" & Input4)
CreateArchiveFolder = f.Path
End Function

End if

 
I don't mean to be rude but I don't see how this code could possibly work (for several reasons)... what is [tt]row[/tt]? what is [tt]f[/tt]? The [tt]fso[/tt] object is used before being defined. The CreateArchiveFolder function is never called. Any file that is seemingly created was NOT created by this script. Try your code before claiming it works.

-Geates



 
Hello,

I solved the problem - Note this code is part of Quick Test Professional script - the "row" is a count of the Datatable input row that the tool is currently on (each row of the DataTable represents a test case)


If objRadioButton1.checked then
msgbox "You have selected the option to archive all text files"


Dim Input4

Input4 = InputBox("Enter Archive Folder Name")
MsgBox ("You entered: " & Input4)
Dim f200
Dim Myfolder
Myfolder=Input4

If row=1 then ' row represents DataTable row - this is a QTP script

dim filesys, newfolder, newfolderpath
newfolderpath = "\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\" & Input4
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(newfolderpath) Then
Set newfolder = filesys.CreateFolder(newfolderpath)
End If

End if



Set fso=CreateObject("Scripting.FileSystemObject")
sour="\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files"
target="\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\" & Input4 &"\"

Set fldr=fso.getFolder(sour)
for each file in fldr.files
'if right(lcase(file.name),4)="x12" then
call mover(lcase(file.path))
'end if
next

sub mover(f1)
f2=replace(f1,"pdf","x12")
' if fso.fileExists(f2) then
' fso.MoveFile f1,target
' fso.MoveFile f2,target
' ' wscript.sleep 60000

If fso.FileExists(f1) then fso.MoveFile f1, target
If fso.FileExists(2) then fso.MoveFile f2, target
'wscript.sleep 60000
wait 1



end sub

End if
 
Yes, the problem is that you only provided a snippet of un-compilable code originally.

It's okay to post a smaller example of your larger problem, in fact it's encouraged strongly! BUT!!!! The catch is that you MUST test your smaller sample code before posting. If the sample doesn't demonstrate the problem, how can anyone help?

Also, this is a great method of self-help... many times, trying to simplify the problem into a smaller sample makes you realize, "Hey wait... it works in my small sample! So why didn't it work in my main code???". Then you should look further at the larger code for something wrong. This is how you learn. This is how I learned vbscript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top