Quick fix: Use xcopy with /k flag (keep attributes). Better: use robocopy instead, which preserves timestamps by default. Example: robocopy C:\Source D:\Backup /e /copy:DAT /dcopy:T. This copies all files including subdirectories, preserves Data, Attributes, Timestamps for files, and copies directory timestamps. Modern recommendation: robocopy over xcopy.
Standard copy command and File Explorer drag-drop reset file dates to “now.” This breaks backup sorting, version checks, sync tools. xcopy and robocopy can preserve original timestamps. robocopy is more powerful and is Microsoft’s recommendation.
Affects: Windows 11 (and Windows 10).
Fix time: ~5 minutes (plus copy time).
What causes this need
Many workflows rely on file dates:
- Backup verification: sort by date to find recent changes.
- Version control: timestamps confirm which is newest.
- Sync tools (rsync, Resilio): use timestamps to detect changes.
- Forensics / compliance: timestamps are evidence.
- Photo / media organization: shoot dates.
Default copy sets Created = now, breaking these workflows.
Method 1: xcopy with /k flag
The legacy route.
- xcopy is the older Windows copy utility. To preserve timestamps:
xcopy "C:\Source" "D:\Backup" /e /i /h /k- /e: include all subdirectories.
- /i: treat destination as directory.
- /h: copy hidden files.
- /k: preserve file attributes (includes read-only state).
- xcopy preserves Modified timestamp by default. Created timestamp is reset.
- For preserving more: limited via xcopy. Better to use robocopy (Method 2).
- For overwrite handling: add
/y(no prompt to overwrite). - For continue on error:
/c. - For verbose output:
/v. - Example with full options:
xcopy "C:\Source" "D:\Backup" /e /i /h /k /y /c
This is the xcopy approach.
Method 2: robocopy for full timestamp preservation
The modern recommendation.
- robocopy is Microsoft’s replacement for xcopy. Built into Windows.
- Basic mirror with timestamps:
robocopy "C:\Source" "D:\Backup" /e /copy:DAT /dcopy:T- /e: copy all subdirectories (including empty).
- /copy:DAT: copy Data, Attributes, Timestamps for files. Default is DAT.
- /dcopy:T: copy directory timestamps too. Default doesn’t copy these.
- This preserves: file Modified timestamp, Attributes (read-only, hidden, etc.), directory Modified timestamp.
- For Created timestamps: not preserved by default. Add:
/copy:DATSOfor Data, Attributes, Timestamps, Security, Owner. Still not Created. Need specific flag. - For Created + Modified + Accessed:
robocopy "C:\Source" "D:\Backup" /e /copy:DATSO /dcopy:DATDATSO for files; DAT for directories.
- For mirror mode (delete files in dest that aren’t in source): add
/mir. Caution: deletes. - For resume / sync:
/z(restartable mode). - For logging:
/log:C:\backup-log.txt.
This is the robocopy way.
Method 3: PowerShell for granular timestamp control
For specific requirements.
- PowerShell can copy with full timestamp preservation:
Get-ChildItem "C:\Source" -Recurse | ForEach-Object { $dest = $_.FullName.Replace("C:\Source", "D:\Backup") if ($_.PSIsContainer) { New-Item -ItemType Directory -Path $dest -Force | Out-Null } else { Copy-Item -Path $_.FullName -Destination $dest -Force $destFile = Get-Item $dest $destFile.CreationTime = $_.CreationTime $destFile.LastWriteTime = $_.LastWriteTime $destFile.LastAccessTime = $_.LastAccessTime } } - This copies each file and explicitly sets all three timestamps.
- Slower than xcopy/robocopy due to per-file Copy-Item overhead.
- For very large file counts: stick with robocopy.
- For mass-renaming with timestamp preservation: extract date from file content (EXIF for photos), set Created/Modified to match.
- For backup verify: after copy, compare hashes:
Get-FileHash "C:\Source\file.txt" -Algorithm MD5 Get-FileHash "D:\Backup\file.txt" -Algorithm MD5Match means data integrity preserved.
This is the granular approach.
How to verify the fix worked
- Compare source and dest: right-click file in source → Properties → note Created, Modified, Accessed dates.
- Same for dest. Dates should match (within microsecond precision, depending on filesystem).
- For batch verify:
dir /tw /tcin cmd. /tw = sort by write time, /tc = sort by create time. - robocopy log: search for “Mismatch” entries. Should be none.
If none of these work
If timestamps don’t preserve: Filesystem limitation: FAT32 has 2-second granularity. exFAT has 10ms. NTFS has 100ns. ReFS has nanoseconds. Filesystem-to-filesystem mismatch: timestamps round. For OneDrive / network shares: server may set Modified to server time. Local files preserved. For permission issues: can’t set timestamps on files where user lacks ownership. Run as Admin or take ownership. For files in use: in-use files may not preserve timestamps. Close apps first or use /B in robocopy (backup mode, requires Admin). For VSS-based backups: Volume Shadow Copy preserves timestamps inherently. Tools like Macrium Reflect use VSS. For Linux / macOS source: ext4 / APFS timestamps may have nanosecond precision; rounding occurs to NTFS. For specific date forensics: tools like ExifTool can read/write timestamps in alternate locations (file metadata).
Bottom line: Use robocopy "C:\Source" "D:\Backup" /e /copy:DAT /dcopy:T for standard timestamp preservation. Add /copy:DATSO /dcopy:DAT for fuller preservation. xcopy /k for legacy compatibility.