I usually use robocopy to move files but had a need to copy some folders with xcopy. Below are some examples that came in handy.
Copy folders and sub-folders
Xcopy "C:\Souorce folder" "D:\Destination folder" /E /H /C /I
/E – Copy subdirectories, including any empty ones.
/H - Copy files with hidden and system file attributes
/C - Continue copying even if an error occurs.
/I - If in doubt, always assume the destination is a folder. e.g. when the destination does not exist.
Copy folders and sub-folders without files
Xcopy "C:\Source folder" "D:\Destination folder" /T /E
/T - Copy the subdirectory structure, but not the files.
/E - Copy subdirectories, including any empty ones.
Copy Folders and subfolders with NTFS and Share permissions
Xcopy "C:\Source folder" "D:\Destination folder" /O /X /E /H /K
/E - Copy folders and subfolders, including empty ones.
/H - Copy hidden and system files also.
/K - Copy attributes. Typically, Xcopy resets read-only attributes.
/O - Copy file ownership and ACL information.
/X - Copy file audit settings (implies /O).
AN INITIAL FULL COPY
xcopy "C:\Source Folder" "\\Destination Server\Share\Folder" /X /H /E /V
COPY FILES OR FOLDERS THAT HAVE CHANGED SINCE THE INITIAL COPY
xcopy "C:\Source Folder" "\\Destination Server\Share\Folder" /X /H /E /V /D /Y
SWITCH EXPLANATION
/X – Copies file audit settings and file ownership and ACL information.
/H – Copies hidden and system files.
/E – Copies directories and subdirectories, including empty ones.
/V – Verifies each new file./D – Copies files changed on or after the specified date (D:m-d-y).
If no date is given, copies only those files whose source time is newer than the destination time.
/Y – Suppresses prompting to confirm you want to overwrite an existing destination file.