Usage:
xcopy "Source" [Destination] /d /s /e /c /i /h /r /k /x /y /f
opt:
/s
Use this option to copy directories, subdirectories, and the files contained within them,
in addition to the files in the root of source. Empty folders will not be recreated.
( Default 只抄 file )
/e
Copies all subdirectories, even if they are empty.
/c
Ignores errors. (corrupt files are skipped and your backup continues)
/i
Use the /i option to force xcopy to assume that destination is a directory.
If you don't use this option, and you're copying from source that is a directory or group of files and copying to destination that doesn't exist,
the xcopy command will prompt you enter whether destination is a file or directory.
/h
Copies files with hidden and system file attributes. By default, xcopy does not copy hidden or system files.
/r
Use this option to overwrite read-only files in destination.
If you don't use this option when you want to overwrite a read-only file in destination,
you'll be prompted with an "Access denied" message and the xcopy command will stop running.
/k
Copies files and retains the read-only attribute on destination files if present on the source files. By default, xcopy removes the read-only attribute.
permission:
/o : Copies file ownership and discretionary access control list (DACL) information.
/x : Copies file audit settings and system access control list (SACL) information (Implies /o).
info:
/f : This shows the full source & destination paths of each file being copied.
other:
/t : Copies the subdirectory structure (that is, the tree) only, not files.
network:
/z : Copies over a network in restartable mode.
The /z and /o (or /x) options conflict: cannot copy security in restartable mode.
Example:
# e: -> f:, log file 放在 f:
xcopy "e:\" "f:\" /s /e /c /i /h /r /k /x /f /y > "f:\filelog.txt" 2>"f:\fileerr.txt"
Other Opts
/d [:date]
Use the xcopy command with /d option and a specific date, in MM-DD-YYY format,
to copy files changed on or after that date.
without specifying a specific date to copy only those files in source that are newer than the same files that already exist in destination.
This is helpful when using the xcopy command to perform regular file backups.
/y
如果是用來做 backup script, 那 /y 是不可少的 !!
因為會有以下情況:
Overwrite E:\$RECYCLE.BIN\UUID\desktop.ini (Yes/No/All)?
/-y : Prompts to confirm that you want to overwrite an existing destination file.
/y : Suppresses prompting to confirm that you want to overwrite an existing destination file.