Link to home
Start Free TrialLog in
Avatar of networkn
networkn

asked on

Script to copy directories only

Hi There!

I want to copy a directory structure from our server to a hard disk for the company doing our acquisition to use. I don't want to copy ANY files, just the folders, so they can see the structure of the folders. I think robocopy does it but I couldn't get it working.

Script needs to run seamlessly on Windows 2008 Server

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Please try the following vbscript
Modify the source folder and destination folder

***************************************************************

source_Folder = "c:\backup" 'path of directory
dest_Folder="d:\backup" ' Path where the directory structure is to be created

On Error resume next

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(source_folder)

WScript.Echo Replace(LCase(objFolder.Path),LCase(source_Folder),LCase(dest_Folder))

objfso.CreateFolder Replace(LCase(objFolder.Path),LCase(source_Folder),LCase(dest_Folder))


ShowSubFolders(objFolder)



Sub ShowSubFolders(objFolder)
   
    Set colFolders = objFolder.SubFolders
   
    For Each objSubFolder In colFolders
       
        WScript.Echo objSubFolder.Path
       
            objfso.CreateFolder Replace(LCase(objSubFolder.Path),LCase(source_Folder),LCase(dest_Folder))
       
        ShowSubFolders(objSubFolder)
       
    Next
   
End Sub
Avatar of networkn
networkn

ASKER

Legen... Wait for it... DARY!

Thanks