Solved

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

Posted on 2011-09-17
12
518 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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
 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 2008 set profile 9 49
Time sync on Domain 5 42
2008 R2 unable to browse website but nslookup works 5 75
"lblTime is not declared" 3 36
Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

730 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