≡ Menu

Copy directory from command line

Windows has two command line utilities to copy files/directories from command line. Copy command can be used to copy files from one folder to another folder. It can’t be used to copy a complete folder to another location on the disk. Xcopy allows us to do this. Let’s see how we can copy a directory along with all the files and sub directories to another location.

Xcopy /E /I SourceFolder DestinationFolder

Let’s say we need to copy a directory called C:\dir1\sourcedir to a location named D:\data\destinationdir.

Now you can run the below command to copy the complete sourcedir to D:\data\destination

Xcopy /E /I C:\dir1\sourcedir D:\data\destinationdir

In the above command we can also use relative paths of the folders with respect to the current directory.

Understanding the command

/E – This option makes sure that empty subfolders are copied to the destination.
/I – Avoids prompting if the destination is a folder or file. Not required if you are adding a trailing ‘\’ to the destination folder, like below.

Xcopy /E C:\dir1\sourcedir D:\data\destinationdir\

/S – This option is not required if you are using /E. /E ensures that all subfolders are also copied to the destination.

7 comments… add one
  • Sam

    yOU Are the Best….i just tried it now…it came very handy wen i needed it…

  • mr.hostile

    0 files copied

    • admin

      What was the exact command you tried? Can you paste the output of dir on the source folder

  • JBK

    Worked like a charm.

  • Vik


    worked fine

    Thanks :)

  • Aditya Thodge

    I want a cmd command to copy folder from Remote to Local computer using Ip address.
    Pl do the needful

  • Larokotuppoo

    I used this cmd before it copies the emty dir n files. But i was looking forward to copy the entire source dir like the folder named “aaa” present in desktop to “c:/ myself”
    It doesn’t do the job.
    Anyother method.

Leave a Comment