Solved

Script to copy directories only

Posted on 2011-03-02
3
819 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 55

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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

688 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