?
Solved

Script to copy directories only

Posted on 2011-03-02
3
Medium Priority
?
820 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 56

Accepted Solution

by:
Bill Prew earned 2000 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
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…
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…
Suggested Courses

800 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