Skip to content

FileSystemWatcher #1

Description

@Reynieri

hi I'm using your script works really good for me. thank you very much
i was wondering if you can add a File System Watcher when ever we finish download any .mkv then the BATCH file get triggered.

i found something that's working for that with powershell, but because i am not a programmer i have no idea of what I'm doing but it think you can make it shine.

### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
    $watcher = New-Object System.IO.FileSystemWatcher
    $watcher.Path = "Z:\media_downloads\downloads"
    $watcher.Filter = "*.mkv*"
    $watcher.IncludeSubdirectories = $true
    $watcher.EnableRaisingEvents = $true  

### DEFINE ACTIONS AFTER AN EVENT IS DETECTED
    $action = { start-process C:\tools\Cleanup_Eng.bat
              }    
### DECIDE WHICH EVENTS SHOULD BE WATCHED 
    Register-ObjectEvent $watcher "Changed" -Action $action
    while ($true) {sleep 5}

source:
https://itectec.com/superuser/how-to-monitor-a-folder-and-trigger-a-command-line-action-when-a-file-is-created-or-edited/
https://powershell.one/tricks/filesystem/filesystemwatcher
https://www.jamsscheduler.com/blog/how-to-execute-a-bat-file-within-a-powershell-job/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions