sift:directory_watchers
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sift:directory_watchers [2025/02/06 15:34] – created sgranger | sift:directory_watchers [2025/02/06 16:49] (current) – sgranger | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==Directory | + | ===== Directory |
- | Watchers are a powerful tool to automate your workflow, | + | Watchers are a powerful tool to automate your workflow, |
- | == Watcher Files == | + | ===== Watcher Files ===== |
- | Watcher files are stored as a XML within | + | Watchers |
- | the AppData | + | " |
+ | {{sift_watcher_xml.png}} \\ | ||
- | [file structure] | ||
- | ==Creating a Watcher== | + | the AppData folder is hidden by default on most windows systems file explorer |
- | Watchers | + | {{windows_hidden_items.png}} \\ |
- | -CreateWatcher | + | ===== Creating, Editing, and Deleting Watchers ===== |
- | name - This is the name used to reference the directory watcher, it will be the name of the xml file | + | In addition |
- | directory - this is the directory that will be watched, this can be passed more than once to watch multiple directories | + | |
- | script - this is a script | + | |
- | Recursive - if this is passed all sub-directories within a watched directory will also be watched. | + | |
- | delay - a delay is important, as if you were to move several file into a watcher directory at once, a trigger would be made for each file. The delay is the number of ms to wait from trigger to execution, the delay will be reset with each new file, ensuring that everything is only triggered once. ALternativly you could set a large delay if you want things to run a certain time after you're done working. | + | |
- | overwrite - if this watcher will overwrite any existing watchers with the same name, otherwise the command will fail | + | |
- | -listwatchers | + | ---- |
+ | ==== -CreateWatcher / -cw ==== | ||
+ | ---- | ||
+ | Create a new Directory Watcher, the file will automatically be saved to the AppData watcher folder, by default all new watchers a set to active. | ||
+ | === Parameters === | ||
+ | == Name (Required) == | ||
+ | This is the name used to reference the directory watcher, it will be the name of the xml file \\ | ||
+ | == Directory (Required) == | ||
+ | This is the directory that will be watched, this can be passed more than once to watch multiple directories \\ | ||
+ | == Script (Required) == | ||
+ | This is a script to be executed upon triggering the watcher, the script can be a .v3s pipeline or a .bat script in the case of a .bat script the first line of the script must be ::SIFT (This ensures only scripts fully intended for sift are executed), the script command can be passed multiple times to execute multiple scripts, the scripts will be executed in the order they are passed. \\ | ||
+ | == Recursive == | ||
+ | If this is passed all sub-directories within a watched directory will also be watched. \\ | ||
+ | == Delay == | ||
+ | The time in milliseconds between a trigger and the execution of the script(s). A delay is important, as if you were to move several file into or out of a watched directory at once, a trigger would be made for each file. The delay will be reset with each new file, ensuring that everything is only triggered once. Alternatively you could set a large delay if you want things to run a certain time after you're done working, or if you do want the watcher to trigger for each individual event, set delay to 0\\ | ||
+ | < | ||
+ | == Overwrite == | ||
+ | If passed this watcher will overwrite any existing watchers with the same name, otherwise the command will fail \\ | ||
+ | === Example === | ||
+ | < | ||
+ | |||
+ | ---- | ||
+ | ==== -listwatchers | ||
+ | ---- | ||
This command will list all watchers and their parameters | This command will list all watchers and their parameters | ||
- | -deleteWatcher | + | ---- |
- | use this command and pass the name of a watcher to delete it. | + | ==== -deleteWatcher |
- | ==Using | + | ---- |
- | For watchers to work Sift must be running in the background, from the system tray, to launch Sift in background mode you can either pass the command -LaunchMinimized, | + | Use this command and pass the name of a watcher to delete it. |
+ | === Parameters === | ||
+ | == name (Required) == | ||
+ | The name of the watcher to delete | ||
+ | === Example === | ||
+ | < | ||
+ | |||
+ | ---- | ||
+ | ==== -ActivateWatcher / -aw ==== | ||
+ | ---- | ||
+ | Used to activate the passed watcher(s) | ||
+ | === Parameters === | ||
+ | == name == | ||
+ | The name of the watcher to be activated can be passed multiple times to activate multiple watchers, if no name is passed all watchers will be activated \\ | ||
+ | === Example === | ||
+ | < | ||
+ | |||
+ | ---- | ||
+ | ==== -DeactivateWatcher / -daw ==== | ||
+ | ---- | ||
+ | Used to deactivate the passed watcher(s) | ||
+ | === Parameters === | ||
+ | == name == | ||
+ | The name of the watcher to be deactivated, | ||
+ | === Example === | ||
+ | < | ||
+ | |||
+ | |||
+ | |||
+ | ===== Using Watchers ===== | ||
+ | For watchers to work Sift must be running in the background, from the system tray, to launch Sift in background mode you can either pass the command -LaunchMinimized, | ||
once sift is running in the background you can interact with it via the system tray icon | once sift is running in the background you can interact with it via the system tray icon | ||
- | from here you can | + | {{sift_tray.png}} \\ |
+ | from here you can \\ | ||
+ | * **Open GUI** - this will open a standard instance of sift with a GUI | ||
+ | * **Open Console** - this will open a console instance of sift, only one console instance of sift can run at a time | ||
+ | * **Quit** - this will close the background instance of sift, all other instances will remain open | ||
+ | * **Disable Start in Tray** - If you have sift set to launch in the background by default, this will disable it | ||
+ | * **Watchers** - if you have any active watchers they will be found here, within this list you can enable or disable individual watchers or enable or disable all watchers | ||
+ | {{sift_tray_watchers.png}} \\ | ||
+ | |||
+ | when a watcher is triggered all v3d pipelines will be run in the background, however all .bat scripts will open a command line interface, if you are running sift commands a command line instance of sift will open, this will not work if you already have sift open on the console, or if a script is triggered while another is still be processed. | ||
+ | |||
+ | ==== BATCH Files ==== | ||
+ | Any .bat file can be executed via Directory Watchers, as long as the first line of the file is a BATCH comment containing SIFT (::SIFT) in order to run Sift commands via directory watchers you must first call Sift and pass it the desired commands | ||
- | open gui - this will open a standard instance of sift with a GUI | + | === Example === |
- | open console - this will open a console instance of sift, only one console instance of sift can run at a time | + | < |
- | quit - this will close the background instance of sift, all other instances will remain open | + | ::SIFT |
- | Disable start in tray - If you have sift set to launch in the background by default, this will disable it | + | |
- | Watchers - if you have any active watchers they will be found here, within this list you can enable or disable individual watchers or enable or disable all watchers | + | |
- | when a watcher is triggered all v3d pipelines will be run in the background, however all .bat scripts will open a commandline interface, if you are running sift commands a command line instance of sift will open, this will not work if you already have sift open on the console, or if a script is triggered while another is still be processed. | + | " |
+ | </ | ||
- | [batch example] | + | Windows BATCH scripting is a powerful tool and much more logic can be put into them, see the [[sift: |
sift/directory_watchers.1738856091.txt.gz · Last modified: 2025/02/06 15:34 by sgranger