How to Monitor a Windows Folder | Take Action for New Files

How to Monitor a Windows Folder for new files and take action 

how to monitor windows folder

It’s hard to manage files especially when you have a lot of files in your desktop. They might get deleted and you won’t even be aware of that. Sometimes a new folder is formed and you are not aware of that. Files get changed which leads to change in the properties of the entire folder. This could be through another application or external source. That’s why we’ve written a tutorial on How to monitor a Windows Folder which will help you to keep track of your folders. So let’s get straight into our article!

10 Tools to Monitor Files and Folders for Changes in Real Time ...

To Monitor a Windows Folder use FilesystemWatcher 

The first step is to instantiate the FileSystemWatcher in PowerShell. You have to choose the folder that you want to find. You can do this by going into the settings. In the “FileSystemWatcher” go to the path parameter which will help you find the folder that you want. If you have a folder on home windows then you will be shelf o find it through FileSystemWatcher.

You will also be able to do it on Linux or Mac.

Events involved in FileSystemWatcher

After getting into the FileSystemWatcher it is important for you to know the events that occur under it. If you want to see the types of events that occur under FileSystemWatcher thence go the Member Type filter where you will find the list of all the events that occur under FileSystemWatcher:

  • Modified
  • Formed
  • Removed
  • Disposed
  • Error
  • Renamed

If any of these events under FileSystemWatcher are detected then the watcher object forms a separate event which then takes actions.

Also, Read How to Reinstall Windows 10 | Do a Fresh Start!

Actions to take 

After setting up the watcher object it is crucial to perform an action once you detect the change. You can write a system log or form replacement with the instant clean pull from the source code. You must have an action block code, to begin with.

$action = {

$path = $event.SourceEventArgs.FullPath

$name = $event.SourceEventArgs.Name

$changetype = $event.SourceEventArgs.ChangeType

Write-Host “File $name at path $path was $changetype at $(get-date)”


This code will appear from setting certain variables. These are created by the events of the watcher object. Once it terminates the variable will terminate as well. It will only have relevant data.

monitor windows folder

Register-object event 

Now that you have set up the FileSystemWatcher you will be able to take actions if something goes wrong. Mostly Register event and Object event are separate so if you want to use them both together you will have to use PowerShell. If you want to use the Register-Object event you must have the following three things:

  • It is an object.
  • To particular event to trigger the action
  • Defined actions

Done! Now Monitor a Windows Folder Easily

By setting up the entire system it is crucial to test it out. Once you test it out you will be able to know if the system is set perfectly or not. If you want to create a new file then click on the PowerShell. Add the following instructions in PowerShell.

New-Item -Path “/home/ubuntu/WatchThisFolder/newFile” -ItemType File

File newFile at path /home/ubuntu/WatchThisFolder/newFile was Created at 09/26/2019 20:49:54

This will help you in debugging as well. Following these steps will help you monitor a Windows folder for new files.

how to test windows folder

Leave a Reply

Your email address will not be published. Required fields are marked *