Last active
August 29, 2015 14:03
-
-
Save juanpabloaj/40f9fa00964d566a8b0b to your computer and use it in GitHub Desktop.
watch new files with powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$folder = 'c:\path\to\file' | |
$filter = '*.*' | |
$fsw = New-Object IO.FileSystemWatcher $folder, $filter | |
$fsw.IncludeSubdirectories = $true | |
$fsw.NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' | |
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { | |
$name = $Event.SourceEventArgs.Name | |
$path = $Event.SourceEventArgs.FullPath | |
Write-Host "The file '$name' '$path'" | |
} | |
#Unregister-Event FileCreated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment