VBScript

Status
Not open for further replies.

TheElise

Baseband Member
Messages
24
Hi all,

Seens as nobody had a clue on how to fix my last problem "including myself" i decided to let it go... :(

However with the helpof another forum we came up with a script that will do the job for us... Horay ... :)

So now i have a VBScript that semi does the job i want it to i was wondering if anyone wanted to help me adapt it to do exactly what i need it to do.

here is a copy of the script from a user on another forum:

Option Explicit

Dim fso, src, dest
Set fso = CreateObject("Scripting.FileSystemObject")
src = "C:\2"
dest = "C:\3"

If fso.FolderExists(src) Then
If Not fso.FolderExists(dest) Then
fso.CreateFolder(dest)
End If
getSubFolders(src)
Else
WScript.Echo "Folder: """ & src & """ doesn't exist."
End If

Function getSubFolders(node)
Dim root, folder, newRoot, file, srcPath, destPath
Set root = fso.GetFolder(node)
For Each file In root.Files
srcPath = fso.BuildPath(node,file.Name)
destPath = fso.BuildPath(dest,file.Name)
If Not fso.FileExists(destPath) Then
WScript.Echo "Copying """ & srcPath & """ to """ & destPath & """"
fso.CopyFile srcPath, destPath, True
Else
WScript.Echo "Error: """ & destPath & """ already exists."
End If
Next
For Each folder In root.SubFolders
'WScript.Echo folder.Name
getSubFolders(folder)
Next
End Function


This script works amazingly well, however i need it ammended slightly to work perfectly and i am not fantastic with VBScripts..

What the script does is copys the files in a directory over to a new directory, however it does not include the sub-directory's of the source folder... It does however copy the files in the sub-directorys.

What i want the script to do is to copy the sub directorys as well, basically i want it to copy the entire folder, sub-folders, files, everything. so i presume only slight ammendments are required... Hopwfully... :)

so if anyone knows how to add that in please post an annmendment and ill be very grateful....
 
Status
Not open for further replies.
Back
Top Bottom