Skip to main content

We’d like to load Google’s advertising tag to measure how our ads perform. It sets cookies and is optional. Privacy policy.

Mudry
Guides

How to monitor a folder for new files on Windows

How to monitor a folder on Windows and act when a new file appears: PowerShell's FileSystemWatcher, a scheduled check, and the traps with half-written files.

Roman Modrytskyi5 min read

Written by the team building Quick File Organizer, folders that organize themselves, by your rules.


Windows has no switch that says "tell me when something lands here". If you want to monitor a folder — to move new downloads, back up new scans or just get a notification — you have to build it from parts, or use a tool that already did. This guide covers the three realistic options and the problems each one runs into.

Option 1: PowerShell and FileSystemWatcher

Windows notifies programs about file changes through an interface that .NET exposes as FileSystemWatcher. PowerShell can use it directly:

$watcher = New-Object System.IO.FileSystemWatcher "$env:USERPROFILE\Downloads"
$watcher.EnableRaisingEvents = $true

Register-ObjectEvent $watcher Created -Action {
  $path = $Event.SourceEventArgs.FullPath
  Write-Host "New file: $path"
}

Run it and every new file in Downloads prints a line. Replace Write-Host with whatever you need: Move-Item, Copy-Item, a script of your own.

It has two limits. The watcher lives inside that PowerShell session, so closing the window stops it; to survive a restart, the script has to be launched at sign-in and kept running. And when many files arrive at once — extracting a large archive, for example — the watcher's buffer can overflow and events are silently dropped.

Option 2: check on a schedule

Task Scheduler has triggers for time, sign-in and system events, but none for "a file was created". The workaround is polling: a task that runs every few minutes and handles whatever it finds.

$folder = "$env:USERPROFILE\Downloads"
Get-ChildItem $folder -File |
  Where-Object LastWriteTime -lt (Get-Date).AddMinutes(-2) |
  Move-Item -Destination "D:\Sorted" -WhatIf

The two-minute filter skips files that are still changing. Polling is slower than a watcher, but it is far more forgiving: nothing is lost if the PC was asleep or the script crashed, because the next run picks up everything that is still there. For most personal use, a check every five minutes is enough.

The half-written file problem

Whichever way you monitor a folder, the same trap is waiting. The "created" event fires when a file starts to exist, not when it is complete. Act immediately and you move a file that is still being written.

Browsers make this visible. Chrome and Edge download to a temporary .crdownload file, Firefox to .part, and rename it when the download finishes. So for downloads, the event you care about is the rename, not the creation:

Register-ObjectEvent $watcher Renamed -Action {
  $path = $Event.SourceEventArgs.FullPath
  if ($path -notmatch '\.(crdownload|part|tmp)$') {
    Write-Host "Download finished: $path"
  }
}

For files copied in by other programs, the usual approach is to wait until the file can be opened exclusively, or until its size has stopped changing for a few seconds.

Option 3: an app that watches for you

If the goal is "sort new files as they arrive", a script is a lot of moving parts: the watcher, the restart handling, the half-written files, the logging. A file organizer packages all of that.

Quick File Organizer lets you add a folder, write rules for it — file type, target folder, operation — and turn on real-time monitoring (part of Pro). It starts with Windows, sits in the tray, and can pause on battery power. Each watched folder can have its own rules, and every action goes into an activity log with a Restore option. Without Pro, the same rules run on demand with one click.

Which option to choose

You wantUse
A one-off or a learning exerciseFileSystemWatcher
Reliability with no extra softwareA scheduled check
New files sorted with no upkeepA file organizer

For what to do once a file is detected, see how to automatically move files.

Common questions

Can I monitor a folder and its subfolders?

Yes. Set $watcher.IncludeSubdirectories = $true before enabling events. Expect more events and a higher chance of buffer overflow in busy folders.

Does watching a folder slow down my PC?

No. The watcher sleeps until Windows reports a change, so an idle folder costs nothing. Polling every few minutes is also negligible for folders with thousands of files rather than millions.

Can I get a notification instead of moving the file?

Yes — the action can be anything. For a simple pop-up, replace the Write-Host line with a call to a notification module such as BurntToast, or send yourself an email from the script.

Was this useful?

Quick File Organizer

Folders that organize themselves, by your rules. Free, no account.

See Quick File Organizer

Keep reading

Know when the next app ships

1 more Windows utility is in development. One short email when each one is ready — nothing else.

Product releases only — roughly once a month. Unsubscribe any time.