How to monitor a folder for a new sub-folder created and then monitor the new subfolder for a file for a specific timeframe? When the file is detected within the timeframe, run another file in a different drive and exit. If the file is not detected within the timeframe, then exit?<\/p>\n
$watcher = New-Object System.IO.FileSystemWatcher\n$watcher.Path = 'Z:\\abc'\n$watcher.Filter ='*.*'\nIncludeSubdirectories = $true\n$watcher.Filter = 'xyz.txt'\n$watcher.EnableRaisingEvents = $true\n\n$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -action {\n$path =$event.SourceEventArgs.FullPath\n $changeType + $Event.SourceEventsArgs. ChangeType\n\n...STUCK HERE\n<\/code><\/pre>\n
Advertisement