When you migrate files into OneDrive for Business using a third-party tool or a manual copy-paste operation, the original modified dates often change to the migration date. This behavior breaks file version tracking, confuses team members who rely on timestamps, and can cause audit compliance issues. The root cause is that the migration process or the copy method does not preserve the last-modified timestamp stored in the file system metadata. This article explains why modified dates are lost, provides a reliable step-by-step fix using Windows built-in tools and PowerShell, and shows you how to verify the dates are correctly preserved.
Key Takeaways: Preserve Modified Dates During OneDrive Migration
- Windows PowerShell
Copy-Itemwith the-Forceand-PassThruswitches: Copies files while preserving original timestamps when used with the correct source and destination paths. robocopycommand with the/COPY:DATSOand/DCOPY:Tflags: Copies file data, attributes, timestamps, security info, and ownership while preserving folder timestamps.- OneDrive sync client version 19.222.1110.0006 or later: Required to accept files with original timestamps when they are placed directly in the OneDrive folder on the local machine.
Why Migrated OneDrive Files Lose Their Original Modified Dates
When you drag and drop files from an external drive or use a migration tool that does not explicitly copy file timestamps, Windows assigns the current date and time as the new modified date. OneDrive for Business syncs the file to the cloud and then propagates this new timestamp to all synced devices. The original modified date is permanently overwritten because the file system sees the copy operation as a new file creation event.
The OneDrive sync client itself does not alter timestamps during a normal upload. The problem originates from the method you use to get the files into the OneDrive folder. Common culprits include:
- Using File Explorer drag-and-drop from a network drive or external hard drive
- Using a third-party migration tool that does not include timestamp preservation in its feature set
- Using the OneDrive web browser upload interface, which always sets the modified date to the upload time
The fix requires using a command-line tool that is designed to copy file metadata, specifically the last-modified timestamp, and then placing those files inside the local OneDrive folder so the sync client uploads them with the correct dates.
Steps to Restore Original Modified Dates on Migrated OneDrive Files
The following method uses the robocopy command, which is built into Windows 10 and Windows 11. It copies files from your source location to your local OneDrive folder while preserving all timestamps. After the copy completes, OneDrive syncs the files to the cloud without changing the dates.
- Open Windows PowerShell or Command Prompt as Administrator
Press the Windows key, type PowerShell, right-click Windows PowerShell, and select Run as administrator. Click Yes if prompted by User Account Control. - Identify the source folder path
Open File Explorer and navigate to the folder that contains your original migrated files. Click the address bar and copy the full path. For example:D:\MigrationBackup\ProjectFiles - Identify your local OneDrive folder path
In File Explorer, locate your OneDrive folder. The default path isC:\Users\YourUserName\OneDrive - YourCompanyName. Click the address bar and copy the full path. - Run the robocopy command with timestamp preservation flags
In the PowerShell window, type the following command and press Enter:robocopy "D:\MigrationBackup\ProjectFiles" "C:\Users\YourUserName\OneDrive - YourCompanyName\ProjectFiles" /E /COPY:DATSO /DCOPY:T /R:3 /W:5
Replace the source and destination paths with your actual folders. The/Eflag copies all subfolders including empty ones. The/COPY:DATSOflag copies Data, Attributes, Timestamps, Security (NTFS permissions), and Ownership. The/DCOPY:Tflag copies folder timestamps. - Wait for robocopy to complete and review the log
robocopy will display a summary showing the number of files copied, skipped, and any errors. Verify that the Files Copied count matches your expectations. If you see errors, note the file paths and check for permissions or path length issues. - Allow OneDrive to sync the new files
Open the OneDrive sync client by clicking the OneDrive cloud icon in the system tray. The sync process will start automatically. Wait for the status to show Up to date. - Verify the modified dates in OneDrive online
Open a web browser, go toonedrive.live.com, and sign in with your work or school account. Navigate to the folder you just copied. Right-click a file and select Details. The Modified date should match the original timestamp from your source folder.
If OneDrive Still Shows the Wrong Modified Dates After Migration
OneDrive Updated the Timestamp After Sync
If you verified the local files have the correct timestamps but OneDrive online still shows the migration date, the sync client may have already uploaded the files before you ran robocopy. In this case, delete the files from OneDrive online, then re-run the robocopy command to the same local folder. OneDrive will re-upload the files with the preserved timestamps.
robocopy Shows Access Denied Errors for Some Files
If robocopy reports access denied errors, the source files may have restrictive NTFS permissions. Run the command with the /B flag to copy in backup mode, which bypasses file permissions. The full command becomes:robocopy "source" "destination" /E /COPY:DATSO /DCOPY:T /B /R:3 /W:5
Files Are Too Large or Paths Are Too Long for robocopy
robocopy supports long file paths natively in Windows 10 version 1607 and later. If you encounter Path Too Long errors, enable long path support in Windows Group Policy. Open Local Group Policy Editor, navigate to Computer Configuration > Administrative Templates > System > Filesystem, enable Enable Win32 long paths, and restart your computer. Then re-run the robocopy command.
Robocopy vs PowerShell Copy-Item for Timestamp Preservation
| Item | Robocopy | PowerShell Copy-Item |
|---|---|---|
| Timestamp preservation | Preserves modified, created, and accessed timestamps with /COPY:DAT |
Does not preserve timestamps by default; requires additional scripting |
| Folder timestamp preservation | Supported with /DCOPY:T |
Not supported natively |
| Security and ownership | Copies NTFS permissions and ownership with /COPY:DATSO |
Does not copy security or ownership |
| Resume capability on failure | Built-in with /Z or /B flags |
Not built-in; requires custom error handling |
| Best use case | Large migrations with many files and subfolders | Simple single-file copy where timestamps are not critical |
You now have a working method to migrate files into OneDrive for Business without losing modified dates. For future migrations, always use robocopy with the /COPY:DATSO and /DCOPY:T flags instead of drag-and-drop. To automate this process for recurring migrations, save the robocopy command as a batch file and schedule it with Task Scheduler. This approach ensures your file timestamps remain accurate for version tracking and compliance audits.