Link to home
Start Free TrialLog in
Avatar of webdott
webdottFlag for United States of America

asked on

vbs , vbscript to create new folder and copy contents in it

i need a vbscript that will do the following:

create a new folder in C:\FILES
allow me to name the new folder with a popup box
then copy directory, subdirectories, and files into that new folder from C:\BlankForms\

thanks
Avatar of webdott
webdott
Flag of United States of America image

ASKER

i have this that will create a new folder,
i now need it to popup so that i can rename it
and copy files from one folder into this one that is created

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

client = "C:\client\new"

If Not objFSO.FolderExists(client) Then 

objFSO.CreateFolder (client)

End If

Open in new window

Avatar of webdott

ASKER

something like this with the copy?

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

client = "C:\client"

copy = "c:\forms"

If Not objFSO.FolderExists(client) Then 

objFSO.CreateFolder (client)

objFSO.CopyFolder (copy) (client)

End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of X Layer
X Layer
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webdott

ASKER

that is it except it does not copy over the folders or files from c:\blankforms
Avatar of webdott

ASKER

thanks - i figured it out with your script.

it should be like this:
 
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

client = "C:\files\" + InputBox("instructions", "popup title", "prefill in box")

If Not objFSO.FolderExists(client) Then 
objFSO.CreateFolder (client)
objFSO.CopyFolder "c:\blankforms",(client)
End If

Open in new window

Avatar of webdott

ASKER

I've requested that this question be closed as follows:

Accepted answer: 500 points for X_layer's comment http:/Q_27313994.html#36555680
Assisted answer: 0 points for webdott's comment http:/Q_27313994.html#36555706

for the following reason:

thanks for all your help!
Avatar of FarWest
FarWest

if the script will do nothing other than that, then it is better to use .cmd and use traditional commands md, xcopy
Avatar of webdott

ASKER

does .cmd or .bat create popup boxes and do the same as above?

thanks
there is something similler

@set /p CopyToF=Please Enter Destination Folder?
this will prompt the user and put the value in CopyToF env. variable which you can use it in your cmd
Avatar of webdott

ASKER

so how would that be written in the .cmd / .bat

thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webdott

ASKER

both are good - i like the vbs popup box better, but bat/cmd is also good.

thanks to both of you