Copy Directory Structure Without Files Using XCOPY Command

Posted on October 31, 2008 by Bo

XCOPY CommandI’m not a DOS guy. I do much better with a graphical user interface (GUI). However, recently I came across an issue where the XCOPY command came in handy.

On my Windows XP machine had a folder that contained over 500 sub-directories. I needed to copy the directory structure without copying the files contained in these directories. After a good bit of searching on my own, I turned to my good friend Jared who pointed me to the XCOPY command.

XCOPY is short for Extended Copy and is the big brother to the copy command found in MS-DOS. It provides many more options for copying multiple files and directories from one drive to another or across a network. Adding certain characters will allow you modify your copy command.

How to copy directory structure without copying files

  • Go to Start and choose Run
  • In the Run dialog box, type: cmd
  • In the command window, use the following syntax.

XCOPY "C:\Existing Folder" "D:\New Copy" /t /e

Upon pressing Enter, I receive the message: “Does C:\Existing Folder specify a file name or directory name on the target (F=file, D=directory)?”

In my instance, I hit D for directory. (If you’re trying to copy file(s) to a file, then you would choose F here). Because of the number of sub-directories, it took a few moments for the process to complete, then I was given a new command line where I typed exit to close the command window.

Below are a few attributes you can append to your XCOPY command to suit your copying needs. For a full range of attributes, check out the Microsoft TechNet site.

  • /t Copies directory structure without copying files. Excludes empty directories. Include /e to copy emtpy directories.
  • /e Copies directory structure, including empty ones. Same as /s /e. Can be used to modify /t.
  • /d :mm-dd-yyyy Copies files changed on or after date provided. If you don’t specify a date, only files from your Source directory that are newer than your Destination directory will be copied, allowing you to update only the files that have been changed.
  • /exclude: filename1 [+filename2] [+filename3] Specifies which files to exclude depending on the string you enter. You can also specify a directory name (\zip\) or file type (.zip) to exclude files in that directory or of that file type.
  • /f Displays filenames of source and destination while copying.
  • /h Copies hidden files and system files which XCOPY does not do by default.
  • /u Copies only the files from source that already exist in destination.

Keep Reading!
Add to Technorati Favorites


One Response to “Copy Directory Structure Without Files Using XCOPY Command”

  1. Olav on July 17th, 2009 5:40 am

    This was exactly what I was looking for. I have used the XCOPY command and it worked just fine. Thank you!

Got something to say?