Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloaj/40f9fa00964d566a8b0b to your computer and use it in GitHub Desktop.
Save juanpabloaj/40f9fa00964d566a8b0b to your computer and use it in GitHub Desktop.
watch new files with powershell
$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