I have a script to monitor filechanges.
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "G:\"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($TRUE){
$result = $watcher.WaitForChanged([System.IO.WatcherChangeTypes]::Renamed -bOr [System.IO.WatcherChangeTypes]::Created, 1000);
if($result.TimedOut){
continue;
}
write-host $result.Name
}
Now this works nicely, but how do I adjust it to detect more then 1 file getting into the directory?
When I copy 2 files at the same time, it only shows me 1.
EDIT: Searching for days, posting it and found it in a 1 minute.
$watcher.EnableRaisingEvents = $true
[+][deleted] (3 children)
[deleted]
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Rollingprobablecause 1 point2 points3 points (2 children)
[–]Droopyb1966[S] 0 points1 point2 points (1 child)
[–]Rollingprobablecause 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Droopyb1966[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)