Skip to content

Instantly share code, notes, and snippets.

@JohnLBevan
Created May 23, 2019 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnLBevan/3afc5f214ede45ea76d79340f80b630f to your computer and use it in GitHub Desktop.
Save JohnLBevan/3afc5f214ede45ea76d79340f80b630f to your computer and use it in GitHub Desktop.
Robocopy command to copy entire directory structure without files
$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