Solved

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

Posted on 2011-09-17
12
517 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
Are your AD admin tools letting you down?

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.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

OfficeMate Freezes on login or does not load after login credentials are input.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

777 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