?
Solved

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

Posted on 2011-09-17
12
Medium Priority
?
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1200 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression

771 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