-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMirrorToStreamer.ps1
30 lines (25 loc) · 1.05 KB
/
MirrorToStreamer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#<BEGIN_SCRIPT>#
#<Set Path to be monitored>#
$SourcePath = "E:\Streamer\"
$DestPath = "\\wdtvlivehub\wdtvlivehub\"
#$DestPath = "E:\Videos\"
$fsw = new-object System.IO.FileSystemWatcher $SourcePath -Property @{
IncludeSubDirectories="true"
NotifyFilter = [System.IO.NotifyFilters]'Filename, LastWrite'
}
$onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action {
Start-Sleep -s 600
$SourcePath = "E:\Streamer\"
$DestPath = "\\wdtvlivehub\wdtvlivehub\"
#$DestPath = "E:\Videos\"
$path = $Event.SourceEventArgs.FullPath
$name = $Event.SourceEventArgs.Name
$changeType = $Event.SourceEventArgs.ChangeType
$timeStamp = $Event.TimeGenerated
If ((Test-Path $DestPath$name) -eq $false) {
New-Item -ItemType File -Path $DestPath$name -Force
}
Copy-Item -Path $SourcePath\$name -Destination $DestPath\$name -recurse -Force
}
$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:30
Register-ScheduledJob -Trigger $trigger -FilePath E:\VagrantTbox\MirrorToStreamer.ps1 -Name MirrorToStreamer