When you need to copy a large folder tree on Windows and skip some files or directories, the safest built-in tool is robocopy.

The command below copies the folder structure and contents while excluding a few paths:

robocopy C:\source C:\destination /E /XD node_modules .git /XF *.log *.tmp

Useful options:

  • /E copies subdirectories, including empty ones.
  • /XD excludes directories.
  • /XF excludes files or file patterns.

If you only want to test the command before writing files, add /L:

robocopy C:\source C:\destination /E /XD node_modules .git /XF *.log *.tmp /L