xcopy-basic-example1


In this example we will use switch /S /E and /W if you want to know about each switch function kindly see my last post about Xcopy switches.

Lets start now 

In this scenario I will copy one folder from derive F to drive E as you can see drive E has no data right now while drive F having 2 folder named Directory1 and EmptyDirectory

xcopy-Basic-examples-s-w


1. We will run below command to copy all directories from F to E drive except empty directory  as well as I will use switch /w that will prompt this message before start the copy "Press any key to begin copying file


xcopy f: e: /s/w


Parameter mean:

/S = copy sub-directories
/W =  message before start the copy "Press any key to begin copying file

Now data has been copied to E drive and you can see in the first line its asking to press any key to begin coping file that switch /W used then all folders are copy except empty folder.


Command Result :

C:\Windows\system32>xcopy f: e: /s/w
Press any key when ready to begin copying file(s)
F:directory1\doc1.rtf
F:directory1\doc2.rtf
F:directory1\file1.txt
F:directory1\file2.txt
F:directory1\file4.txt
F:directory1\file5.txt
F:directory1\subfolder1\subfile1.txt
F:directory1\subfolder1\subfile2.txt
F:directory1\subfolder1\subfile3.txt
9 File(s) copied

Note: All files and folders are copied except folder named "Empty directory"