Solved

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

Posted on 2011-09-17
12
510 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
A procedure for exporting installed hotfix details of remote computers using powershell
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

19 Experts available now in Live!

Get 1:1 Help Now