Solved

Script to copy directories only

Posted on 2011-03-02
3
802 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 51

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now