Hello:
My script does almost everything I want.
I pick the file I'm going to copy with the UserAccounts Dialog.
This file name is xclude.txt
I'm writing this out to another folder and adding a incrementing number to the end so I have multiple copies depending on what the user enters into the inputbox function.
It writes everything out correctly except for one thing.
It uses my variable name (strpath) instead of the name inside the variable which is (xclude.txt).
Any help would be greatly appreciated, and thank you.
Option Explicit
Dim objDialog, oFSO, intResult, pad, nbr, i, strpath
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Text Files|*.txt|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen
If intResult <> 0 Then
MsgBox objDialog.FileName
End If
strpath = objDialog.FileName
nbr = InputBox ("Enter the number of Files to Create")
pad = "0"
'MsgBox objDialog.FileName, vbOK
Set oFSO = CreateObject("Scripting.FileSystemObject")
i = 1
While i < 10
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & pad & i & ".txt"
i = i+1
Wend
Do while i =< CInt(nbr)
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & i & ".txt"
i = i+1
Loop
WScript.Quit
My script does almost everything I want.
I pick the file I'm going to copy with the UserAccounts Dialog.
This file name is xclude.txt
I'm writing this out to another folder and adding a incrementing number to the end so I have multiple copies depending on what the user enters into the inputbox function.
It writes everything out correctly except for one thing.
It uses my variable name (strpath) instead of the name inside the variable which is (xclude.txt).
Any help would be greatly appreciated, and thank you.
Option Explicit
Dim objDialog, oFSO, intResult, pad, nbr, i, strpath
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Text Files|*.txt|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen
If intResult <> 0 Then
MsgBox objDialog.FileName
End If
strpath = objDialog.FileName
nbr = InputBox ("Enter the number of Files to Create")
pad = "0"
'MsgBox objDialog.FileName, vbOK
Set oFSO = CreateObject("Scripting.FileSystemObject")
i = 1
While i < 10
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & pad & i & ".txt"
i = i+1
Wend
Do while i =< CInt(nbr)
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & i & ".txt"
i = i+1
Loop
WScript.Quit