Skip to content

Instantly share code, notes, and snippets.

@imorrish
Created July 24, 2018 06:48
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 imorrish/07d6b27398addedeff2699f42da5efcf to your computer and use it in GitHub Desktop.
Save imorrish/07d6b27398addedeff2699f42da5efcf to your computer and use it in GitHub Desktop.
PowerShell script to monitor folder for new/changed image and upload to ATEM media pool
# File System Watcher to upload image to ATEM media pool
Function ATEMUploadImage
{
param
(
[String]$File,
[Int]$Slot,
[string]$ATEMip
)
# Just use command line utility as dll may conflict with JustMacros
Write-Output "Uploading image $($File)"
$exe = "C:\utils\mediaupload.exe"
& $exe $ATEMip $Slot $File
}
#create watcher
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path ="C:\data\images"
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
#wait in loop for file
while($TRUE){
$result = $watcher.WaitForChanged([System.IO.WatcherChangeTypes]::Changed -bor [System.IO.WatcherChangeTypes]::Renamed -bOr [System.IO.WatcherChangeTypes]::Created, 1000);
if($result.TimedOut){
continue;
}
ATEMUploadImage "c:\data\images\$($result.Name)" 6 "192.168.1.8"
}
@imorrish
Copy link
Author

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