Solved

Script to copy directories only

Posted on 2011-03-02
3
809 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:networkn
3 Comments
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 35023722
Actually this can be done with the built in XCOPY command, something like this:

xcopy c:\from d:\to /T /E

~bp
0
 
LVL 12

Expert Comment

by:prashanthd
ID: 35023735
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
0
 

Author Closing Comment

by:networkn
ID: 35023839
Legen... Wait for it... DARY!

Thanks
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Synchronize a new Active Directory domain with an existing Office 365 tenant
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

831 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