Created
May 23, 2019 11:28
-
-
Save JohnLBevan/3afc5f214ede45ea76d79340f80b630f to your computer and use it in GitHub Desktop.
Robocopy command to copy entire directory structure without files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$source = '\\path\to\source' | |
$destination = '\\path\to\dest' | |
robocopy "$source" "$destination" /zb /e /xf * | |
<# | |
See https://ss64.com/nt/robocopy.html for notes | |
/zb - If you get access denied on a folder, try using backup mode to access it (see http://www.rainingforks.com/blog/2015/suggested-robocopy-switches-explained.html for detail) | |
/e - Copy subfolders (/s), including empty ones. | |
/xf * - exclude files matching a filename pattern; in this case any filename, so only copy directories | |
Note: dest will contain the child folders of source; not source itself. | |
e.g. \\path\to\source\sub1 will be copied to \\path\to\dest\sub1; not \\path\to\dest\source\sub1 | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment