Solved

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

Posted on 2011-09-17
12
514 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:webdott
  • 8
  • 3
12 Comments
 

Author Comment

by:webdott
ID: 36555632
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

0
 

Author Comment

by:webdott
ID: 36555659
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

0
 
LVL 11

Accepted Solution

by:
X_layer earned 300 total points
ID: 36555680
Is this what you're looking for:
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

client = "C:\files\" + InputBox("Enter folder name:", "Create folder", "Folder name")
copy = "c:\BlankForms"

If Not objFSO.FolderExists(client) Then 
objFSO.CreateFolder (client)
objFSO.CopyFolder (copy) (client)
End If

Open in new window

0
 

Author Comment

by:webdott
ID: 36555696
that is it except it does not copy over the folders or files from c:\blankforms
0
 

Author Comment

by:webdott
ID: 36555706
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

0
 

Author Comment

by:webdott
ID: 36565024
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!
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 12

Expert Comment

by:FarWest
ID: 36555921
if the script will do nothing other than that, then it is better to use .cmd and use traditional commands md, xcopy
0
 

Author Comment

by:webdott
ID: 36556517
does .cmd or .bat create popup boxes and do the same as above?

thanks
0
 
LVL 12

Expert Comment

by:FarWest
ID: 36556687
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
0
 

Author Comment

by:webdott
ID: 36564483
so how would that be written in the .cmd / .bat

thanks
0
 
LVL 12

Assisted Solution

by:FarWest
FarWest earned 200 total points
ID: 36565025
@Echo off
@set /p COPYTOF=Please Enter Destination Folder?
@xcopy C:\BlankForms /s /e  C:\Files\%COPYTOF%\
@Echo Done

0
 

Author Closing Comment

by:webdott
ID: 36577597
both are good - i like the vbs popup box better, but bat/cmd is also good.

thanks to both of you
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now