Move files on a schedule with Task Scheduler: the setup and the gotchas
By Jordan Ellis Published 11 min read
On this page (11 sections)
- The short version
- An automation bot creator for moving files on a schedule is often unnecessary
- Build the move with one robocopy command and one scheduled task
- Check for files before the scheduled move runs
- Robocopy return codes use a bitmask
- Locked files need limited retries and a later run
- Use one account and one path for network destinations
- Test the job as the scheduled account before trusting it
- Alert when a move fails or stops arriving
- Pay for cloud automation when the trigger lives outside a folder
- Questions people still ask
In short: An automation bot creator for moving files on a schedule isn't necessary for most small teams. Task Scheduler and robocopy handle timed local or network moves without licence fees. Choose Power Automate or Zapier when the workflow depends on forms, email, cloud apps, or other events outside the file system.
Part of our guide on automate invoice emails every monday for 150 customers
Robocopy can report a successful run when it copied nothing. An empty source and a finished move can both produce low exit codes.
| Tool cost | free with Windows |
|---|---|
| Robocopy return code | bitmask, not a simple status number |
| Failure indicator | 8 or higher includes failed copies |
| Locked files | retried, then skipped |
| Suggested retry setting | /R:3 /W:5, adjust after testing |
| Mapped drives | unavailable to other task accounts |
| Official references | learn.microsoft.com/windows-server/administration/windows-commands/robocopy |
The short version
- Robocopy's /MOV switch deletes the source after a successful copy, making it the closest safe equivalent to cut and paste on a timer.
- Robocopy uses a bitmask return code. Codes 0 through 7 describe successful or non-fatal results, while 8 and above indicate failures.
- A scheduled task runs as the account you name. That account needs permission for every local folder and network share it touches.
- Files held open by another program are skipped after the configured retries. They aren't queued automatically.
- A wrapper can check for files, run robocopy, write a log and alert when the return code shows failure.
An automation bot creator for moving files on a schedule is often unnecessary
Task Scheduler and robocopy cover moves between folders on one machine or a reachable network share. Robocopy ships with Windows, runs from a command line, and can append a log for every run.
The pair can select files, copy them, delete verified source copies, record results and trigger an alert. You lose the visual builder, not the basic file operation.
Paid tools earn their fee when the trigger lives outside the file system. An email attachment, online form or cloud spreadsheet needs a connector that robocopy doesn't provide.
A scheduled task also depends on its host machine. If that machine sleeps, shuts down or loses its network, the move waits for another run. We go through Synology NAS power on step by step elsewhere on the site.
- Local folder to local folder: robocopy handles this completely.
- Workstation to network share: robocopy handles this with the right task account and share permissions.
- Cloud storage folder to local folder: robocopy works if the cloud client keeps a synced local copy.
- Email attachment to folder: robocopy cannot start this without another tool.
Build the move with one robocopy command and one scheduled task
The command takes a source folder, a destination folder and switches controlling the copy. Test it manually before adding Task Scheduler.
Use this example: robocopy "C:\Invoices\In" "D:\Archive\Invoices" /MOV /Z /R:3 /W:5 /LOG+:"C:\Logs\invoice-move.log" /TEE /NP.
The /MOV switch removes each source file after a successful copy. The /Z switch supports restartable copies. /R:3 retries three times, while /W:5 waits five seconds between attempts. Before you commit to anything, it is worth looking at integromat plan for google drive to s3.
Microsoft documents the switches and return values at https://learn.microsoft.com/windows-server/administration/windows-commands/robocopy. The retry values above are a practical starting point, not a universal rule.
- Open Command Prompt and run the robocopy line by hand with /L added. Remove /L only after the list looks correct.
- Create a task in Task Scheduler rather than using the Basic Task wizard.
- On General, choose Run whether user is logged on or not and select Run with highest privileges when the job needs it.
- On Triggers, choose a daily or hourly schedule. Add a suitable stop limit for a stalled run.
- On Actions, choose Start a program. Set Program/script to C:\Windows\System32\robocopy.exe, or call the wrapper instead.
- Use this Arguments line for a wrapper: C:\Scripts\move-invoices.cmd. Set Start in to C:\Scripts.
- On Conditions, clear the AC-power condition for a desktop if the job should run on battery.
- On Settings, choose a sensible restart policy and prevent overlapping instances if a run can last longer than the interval.
- Run the task manually, then inspect the log and the Last Run Result field.
| Switch | What it does | Failure it prevents |
|---|---|---|
| /MOV | Deletes source files after a successful copy | Duplicates left in both folders |
| /Z | Uses restartable copy mode | Restarting large transfers after a network drop |
| /R:3 /W:5 | Limits retries and waits | Effectively endless retries on a locked file |
| /LOG+ | Appends to the log | Losing evidence from earlier runs |
| /TEE /NP | Shows output and removes progress noise | Unreadable console and log output |
Check for files before the scheduled move runs
A wrapper can skip empty runs and evaluate robocopy's result in one place. The batch file below checks regular files in the source, runs the move and posts failures to a webhook.
Replace the source, destination, log and webhook values. The webhook example expects a service accepting a JSON message with curl. Before you commit to anything, it is worth looking at concurrency needed for 200 invoicing jobs.
Robocopy's default retry behaviour is very large. Set /R and /W to reasonable values so a locked file doesn't keep the task occupied indefinitely.
- Save this as C:\Scripts\move-invoices.cmd.
- Create C:\Logs before the first run.
- Replace the webhook URL with your alert endpoint, then test the script from a command prompt.
- Schedule the wrapper, not robocopy.exe, in the Action field.
Robocopy return codes use a bitmask
Don't treat the return value as a simple success number. Robocopy combines result bits, so a value can describe more than one condition.
Microsoft's robocopy documentation lists the common meanings: 0 means no files needed copying, 1 means files copied, 2 means extra files or directories were found, 4 means mismatched files or directories were found, and 8 means at least one copy failed. Code 16 indicates a fatal error.
Codes below 8 generally indicate no copy failure, but the individual bits can combine. Code 3, for example, contains the copied and extra-item bits.
Use the official mapping at https://learn.microsoft.com/windows-server/administration/windows-commands/robocopy when writing monitoring rules. Alert on 8 or higher for failed copies, then inspect the log for the exact cause.
- 0: no files needed copying.
- 1: files copied successfully.
- 2: extra files or directories were found.
- 4: mismatched files or directories were found.
- 8: one or more files failed to copy.
- 16: a fatal error occurred.
Locked files need limited retries and a later run
Robocopy retries a locked file according to /R and /W, then moves on. The source file remains in place when the copy fails.
An invoice open in Excel can block the overnight move while other files succeed. The log records the problem, but the file isn't placed in a queue for later handling.
Set /R:3 and /W:5 as a starting point for office documents. Increase them only after measuring how long applications usually hold files open.
Database files and active application data need application-level backups. A file copy cannot guarantee a consistent database state.
| Situation | Does it block? | What you see |
|---|---|---|
| File open in Excel or Word | Often | The file remains in the source and the log records a failure |
| File open in Notepad | Depends on access mode | It may copy if no exclusive lock exists |
| Database file in use | Often | The copy may fail or lack application consistency |
| File still being written by a scanner | Often | A later run can move it after the writer closes it |
- Limited retries handle brief saves
- Logs show files that stayed behind
- No extra service is needed
- A skipped file is not queued automatically
- An open document can block the move
- You need an alert to notice repeated skips
Use one account and one path for network destinations
A mapped drive letter belongs to a user session. A task running as SYSTEM or another account normally won't see that mapping.
Use a UNC path such as \\server\share\folder in the command or wrapper. Give the selected task account both share and NTFS permissions.
For a domain account, open Task Scheduler, create the task, choose Run whether user is logged on or not, click Change User or Group, enter CONTOSO\FileMover, then select OK. Windows asks for that account's password when you save the task.
Task Scheduler stores credentials for this run mode, subject to local policy. Don't place the password in the batch file or command arguments.
- Create a dedicated domain service account with only the required folder permissions.
- Use UNC paths instead of mapped drive letters.
- In General, select the domain account and Run whether user is logged on or not.
- Enter the account password when prompted. Re-enter it after password rotation.
- Test the task while signed out, not only while your desktop is open.
| Destination | Works under a scheduled task? | Catch |
|---|---|---|
| Local fixed drive | Yes | The task account needs folder access |
| Mapped network drive | Only for the session that created it | Other accounts may not see the letter |
| UNC path to a file server | Yes | The account needs share and NTFS rights |
| UNC path to a NAS | Yes | The share must be reachable at run time |
| USB drive | Unreliable | The drive may be absent or receive another letter |
Test the job as the scheduled account before trusting it
A successful interactive test proves very little if the task uses another identity. Test access, the command and the wrapper as the selected account.
Run a shell as the domain account with: runas /user:CONTOSO\FileMover cmd.exe. Enter the password, then test dir \\server\share\folder and the robocopy command from that window.
For a local account, use runas /user:COMPUTERNAME\FileMover cmd.exe. The account must have access to the source, destination and log folder.
Sysinternals PsExec offers another option: psexec.exe -i -u CONTOSO\FileMover cmd.exe. Download it from Microsoft's Sysinternals site and protect the supplied credentials.
After testing, sign out and run the task manually. Confirm the log, destination and Last Run Result while no File Explorer session is open.
Alert when a move fails or stops arriving
A log nobody reads is decoration. Capture the raw return code, keep the log local and send a message when the code reaches 8 or higher.
The batch wrapper above posts a webhook alert. PowerShell can send an email through an approved relay, but SMTP settings differ between organisations and should not be hard-coded.
A successful empty run still deserves operational attention if files should arrive every day. Track the log timestamp or count files in the source with a separate health check.
Pay for cloud automation when the trigger lives outside a folder
Power Automate or Zapier makes sense when an email, form, cloud row or payment starts the process. Task Scheduler cannot monitor those events by itself.
A cloud service also suits jobs that must run while every office computer is switched off. The trade-off is a recurring fee and another service to monitor.
Choose the local route for a folder-to-folder move on hardware you control. The command is easier to audit, and the files stay within your environment.
Choose a visual tool when several non-technical people need to edit the workflow. That interface is the reason to pay.
- Email or cloud form starts the process: use a connector.
- No reliable always-on local machine exists: use a cloud runner.
- A local folder moves to a share: use Task Scheduler and robocopy.
- Several staff edit the workflow: consider a visual automation service.
- Connects services without local folders
- Runs independently of an office computer
- Gives non-technical staff a visual editor
- Adds a recurring per-user or per-flow cost
- Creates another service to monitor
- Overkill for a simple local move
Task Scheduler and robocopy handle folder moves without a licence fee when the account, paths, retries and alerts are configured properly. Pay for cloud automation when the trigger lives outside a folder.
Questions people still ask
Why did my scheduled robocopy task run successfully but move nothing?
Read the return code and log. Code 0 means no files needed copying. Code 1 means files copied. Codes 2 and 4 describe extra or mismatched items, while 8 indicates copy failures. Open files and permissions are common causes.
Can a scheduled task see a mapped drive letter?
Only when the mapping exists in the same user session and security context. Use a UNC path such as \\server\share\folder and grant the task account the required permissions.
What is the safest way to test a moving job?
Run the command with /L first. It lists the proposed actions without changing files. Then test the wrapper with a small sample and run the final task as its configured account.
Does a moved file ever remain duplicated?
Yes, if the copy succeeds but source deletion fails, or if /MOV is omitted. Review the log and compare source and destination after a test run.
How many retries should a locked file get?
Start with /R:3 /W:5 for ordinary office files. Measure actual lock durations before increasing those values. A file held open all day won't benefit from a long retry window.