How to Use Robocopy for Recursive File Copying in Tech Support

Abstract: Resolve recursive file copying issues in Windows by using Robocopy with the /E or /S switch to replicate directory structures while preserving attributes and timestamps.

Created: 2026-08-08 by

Use the robocopy command with the /E or /S switch to recursively copy all subdirectories from a source folder to a destination. This built-in Windows utility handles complex directory structures efficiently, preserving attributes and timestamps while skipping empty folders if desired.

Understanding Robocopy Basics

Robocopy (Robust File Copy) is a command-line directory replication tool included in Windows Vista and later versions, as well as Windows Server operating systems. It is significantly more robust than the traditional copy or xcopy commands, offering better error handling, multi-threaded copying, and resume capabilities. For tech support professionals, mastering this tool is essential for migrating data, backing up systems, or synchronizing large file sets across network shares.

The basic syntax requires at least three arguments: the source path, the destination path, and optionally, a list of files to copy. If no file specification is provided, Robocopy defaults to copying all files. The command structure is straightforward:

robocopy <Source> <Destination> [file[s]...]

While simple copies are possible, the true power of Robocopy lies in its extensive array of switches that control how data is transferred. Without these switches, Robocopy only copies files and does not replicate the directory structure by default. To achieve recursive copying, you must explicitly instruct the tool to include subdirectories.

Recursive Copying with /E and /S

To copy an entire folder tree, including all subdirectories, you need to use one of two primary switches: /E or /S. Understanding the difference between them is critical for ensuring your backup or migration process works as intended.

  • /E: Copies all subdirectories, including empty ones. This is the most common choice when you want an exact mirror of the source structure, regardless of whether the folders contain files.
  • /S: Copies subdirectories but excludes empty directories. Use this if you want to clean up the destination by removing folder structures that do not hold any data.

For example, to copy every file and folder from C:\Data\Projects to D:\Backup\Projects, including empty folders, you would run:

robocopy C:\Data\Projects D:\Backup\Projects /E

If you prefer to omit empty folders from the destination, replace /E with /S. This distinction prevents clutter in your target drive while still moving all substantive data. Many technicians find /E safer because it preserves the exact hierarchy, which can be useful for restoring specific nested configurations later.

Essential Flags for Reliable Transfers

Beyond recursion, several other flags are standard practice in professional tech support workflows. These options ensure data integrity, handle network interruptions gracefully, and provide detailed logging for troubleshooting.

The /MIR flag mirrors a directory tree. It is equivalent to using /E combined with /PURGE, which deletes files and directories in the destination that no longer exist in the source. Be extremely cautious with /MIR as it can inadvertently delete data on the target drive if used incorrectly. For safe recursive copying without deletion, stick to /E.

Adding /Z enables restartable mode. If the copy operation is interrupted due to a network drop or system crash, you can rerun the same command, and Robocopy will resume from where it left off rather than starting over. This is invaluable for large transfers over unstable connections.

Logging is another crucial component. Using /LOG+:path appends output to a text file, allowing you to review exactly what was copied, skipped, or failed after the job completes. This is vital for audit trails and diagnosing why certain files might not have moved.

Handling Permissions and Attributes

By default, Robocopy attempts to preserve security settings (ACLs), timestamps, and file attributes. If you are copying between different domains or user profiles, you might encounter access denied errors. In such cases, adding /COPY:DAT limits the copy to Data, Attributes, and Timestamps, skipping Security descriptors. This often resolves permission issues while maintaining file integrity.

For more information on measuring performance during these transfers, see our guide on How to Measure Robocopy's Copy Speed and Files Skipped/Copied?. Monitoring speed helps identify bottlenecks in your storage infrastructure.

Common Scenarios and Best Practices

Tech support scenarios often involve specific constraints. For instance, copying to a portable USB drive may result in unexpected hidden or system folders appearing. If you encounter issues where the destination becomes corrupted or filled with system files, refer to our article on Unaccountably, Folder Robocopied to Portable USB Drive on Laptop PC Becomes System + Hidden - What to Do? for troubleshooting steps.

Another common concern is preventing accidental overwrites. Robocopy has sophisticated logic for handling existing files. By default, it skips files that already exist in the destination. If you need to force overwrites, use /XF to exclude specific files or adjust the copy behavior with /FFT for FAT time tolerance. However, for general recursive backups, the default skip behavior is usually preferred to avoid losing newer data on the target.

When dealing with non-empty folders that need to be moved rather than copied, be aware that Robocopy’s move functionality (/MOVE) will fail if the destination folder contains items. Always ensure the destination root is empty before initiating a move operation to avoid errors related to deleting non-empty folders.

Frequently Asked Questions

Does Robocopy copy empty folders by default?

No, Robocopy does not copy empty folders by default. You must explicitly add the /E switch to include all subdirectories, even those that are empty. Without this switch, only files and their immediate parent directories are replicated.

What is the difference between /E and /MIR?

The /E switch copies all subdirectories including empty ones but does not delete anything from the destination. The /MIR switch mirrors the source to the destination, meaning it deletes files and folders in the destination that no longer exist in the source. Use /MIR with caution as it is destructive to the destination.

How can I resume a failed Robocopy transfer?

Add the /Z switch to your command line. This enables restartable mode, which allows Robocopy to pick up where it left off after a network interruption or system reboot. Without /Z, the tool typically restarts the entire copy process from the beginning.

Why does Robocopy skip some files during copying?

Robocopy skips files that already exist in the destination and have identical or newer timestamps. This is designed to prevent unnecessary overwrites. If you need to overwrite existing files, you must use additional switches like /XO (exclude older) removal or simply accept that the default behavior protects newer data.

Can Robocopy preserve file permissions during the copy?

Yes, by default Robocopy attempts to preserve security descriptors (ACLs). However, if you lack administrative privileges or are copying across different domains, this may cause errors. You can control this behavior using the /COPY flag, specifying which attributes to copy, such as /COPY:DAT for data, attributes, and timestamps only.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More