Hi,
Can any one suggest me , method which is available in VB Script to copy the number of FILES which is available in a folder to another folder in another Drive (Say for example Z :/-Drive one of the folder to C:/ Drive one of the existing folder ) .
Kindly let me know if you need more information..
Thanks in Adavance !
Regards,
Nagaraj
1 1013
Save this with File Extention .vbs - '---------------------------------------------------------
-
'Written by Vic Laurie, January, 2006
-
'Modified by Knut H, October 2007
-
'All rights reserved. Provided as is
-
'with no guarantees, express or implied
-
'User assumes all responsibility
-
'---------------------------------------------------------
-
-
'Description- Copies files with specified extension from user selected
-
'folder and its subfolders to a user selected destination folder.
-
'Pre-existing files of the same name will be overwritten
-
'if they are older than the file being copied.
-
'Uses Xcopy with switches /c /h /k /r /y /i /q /s /d
-
-
Option Explicit
-
Dim sFldrInput1, sFldrInput2, introMsg, sExtension
-
introMsg = msgBox("This program copies files from a specified folder." & vbCrLf & "Files from subfolders will also be copied." & vbCrLf & "Pre-existing files of the same name will be overwritten if they are older."& vbCrLf & "If you are copying many files it may take a few minutes."& vbCrLf & "A message will appear when copying is finished.",vbOKCancel)
-
If introMsg = vbCancel Then
-
Wscript.Quit
-
End If
-
ChooseFolder sFldrInput1,"Select the source folder:"
-
ChooseFolder sFldrInput2, "Select the destination folder:" & vbCrLf & "Choose New Folder and type the folder name you want, unless you want to use an existing folder." & vbCrLf & "The script has to be modified further if you want to copy existing folder names as well."
-
ChooseExtension sExtension
-
CopyFiles sFldrInput1, sFldrInput2, sExtension
-
Wscript.Quit
-
-
-
sub ChooseFolder(sFldrChoice, sSelectionString)
-
dim objShell, objFolder, objFolderItem, strPath, msgValue
-
Const DESK_TOP = &H10&
-
Const WINDOW_HANDLE = 0
-
Const OPTIONS = 0
-
sFldrChoice = ""
-
Set objShell = CreateObject("Shell.Application")
-
Set objFolder = objShell.Namespace(DESK_TOP)
-
Set objFolderItem = objFolder.Self
-
strPath = objFolderItem.Path
-
Set objShell = CreateObject("Shell.Application")
-
Set objFolder = objShell.BrowseForFolder _
-
(WINDOW_HANDLE, sSelectionString, OPTIONS, strPath)
-
-
If objFolder Is Nothing Then
-
Wscript.Quit
-
End If
-
-
Set objFolderItem = objFolder.Self
-
sFldrChoice = objFolderItem.Path
-
-
msgValue = msgBox("You selected "& sFldrChoice, vbOKCancel)
-
If msgValue = vbCancel Then
-
Wscript.Quit
-
End If
-
If Len(sFldrChoice) = 3 then
-
chkForDrv sFldrChoice
-
End if
-
End sub
-
-
sub CopyFiles (sSourceFldr,sBkupFldr, sExtension)
-
-
Const CopyX = "xcopy "
-
Const sWildCard = "\*."
-
Const sSwitches = " /c /h /k /r /y /i /q /s /d"
-
dim sStatement
-
dim objWshell
-
Dim oIE, oIEDoc, sMsg
-
sStatement= copyX & chr(34) & sSourceFldr & sWildcard & sExtension & chr(34) & " " & chr(34) & sBkupFldr & chr(34) & sSwitches
-
-
'The next part is just to display a message while copying
-
set objWshell=Wscript.CreateObject("Wscript.Shell")
-
Set oIE = Wscript.CreateObject("InternetExplorer.Application")
-
oIE.Navigate "about:blank"
-
do while oIE.busy : wscript.sleep 10 : loop
-
Set oIEDoc = oIE.Document
-
oIE.AddressBar = False
-
oIE.StatusBar = False
-
oIE.ToolBar = False
-
oIE.height=200
-
oIE.width=300
-
oIE.Resizable = False
-
oIE.Visible = True
-
sMsg= "<p><center>Files are being copied.<br>Please wait.<br>Large folders may take several minutes.</center></p>"
-
oIEDoc.Body.Innerhtml= sMsg
-
-
'copy the files
-
objWshell.Run sStatement,7,true
-
-
Set oIEDoc = Nothing
-
oIE.Quit
-
Set oIE = Nothing
-
set objWshell = Nothing
-
msgBox "Copying job done"
-
End sub
-
-
Sub chkForDrv(sFldrChoice)
-
Dim oRe, bMatch
-
set oRe = New RegExp
-
oRe.pattern = "[a-zA-Z]:\\$"
-
bMatch= oRe.Test(sFldrChoice)
-
If bMatch Then sFldrChoice= Left(sFldrChoice, 2)
-
End sub
-
-
Sub ChooseExtension(sExtension)
-
-
-
'Changed this to copy any file in selected folder
-
sExtension = "*"
-
-
'Original script used this:
-
'sExtension = InputBox("Enter extension of files to be copied.", "Name of extension")
-
-
If sExtension = "" Then
-
Wscript.Quit
-
End If
-
chkForDot sExtension
-
End sub
-
-
Sub chkForDot(sExtension)
-
Dim lenExt, truncStr
-
lenExt = Len(sExtension)
-
truncStr =left(sExtension,1)
-
If truncStr = "." then
-
sExtension = right(sExtension,lenExt-1)
-
End if
-
End sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: deko |
last post by:
In regard to running php scripts with cron -
Here is a sample script:
<?php
//debug.php
echo "<br> This is a test";
?>
I can call debug.php from a web page on my site like this:
|
by: Les Juby |
last post by:
A year or two back I needed a search script to scan thru HTML files
on a client site. Usual sorta thing. A quick search turned up a
neat script that provided great search results. It was fast,...
|
by: Mike Biang |
last post by:
Is there a way to request a server script through javascript without
having the browser navigate to another page? Similar to the effects
of calling the server.execute method in ASP. Is anyone...
|
by: Nath |
last post by:
Please help!?
I am new to writing html, javascript, pretty new to MySQL but quite
proficient at writing Perl and i'm a quick learner.
I am building a database driven website and i am a little...
|
by: Ian Giblin |
last post by:
I am an experienced C programmer, learning C++ by writinging a
mathematical toolkit in the framework of a script interpreter. I am
posting here to ask for advice (or references) on the object...
|
by: Bob Sanderson |
last post by:
I have a script that reads the computer date and writes it to a copyrite
footer on a web page. The idea is to avoid having to update each page
manually at the start of a new year. It works fine...
|
by: ZMan |
last post by:
Scenario:
This is about debugging server side scripts that make calls to
middle-tier business DLLs. The server side scripts are legacy ASP 3.0
pages, and the DLLs are managed DLLs...
|
by: kelly |
last post by:
Hi,
I don't have a code to show you, what I need are references or
algorithms so that I'm in a right track.
By the way, thanks for introducing me the array or arrays. Now I can
continue my...
|
by: Angus |
last post by:
I have a web page with a toolbar containing a Save button. The Save
button can change contextually to be a Search button in some cases.
Hence the button name searchsavechanges.
The snippet of...
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |