Created
December 19, 2024 15:14
-
-
Save Cdaprod/0880f39cb1f77b5422ad4898f0f3f1c1 to your computer and use it in GitHub Desktop.
PowerShell Windows Watcher ~> Nikon Z7 Video Sync: This approach ensures your videos are always synced to the specified folder (C:\SyncedVideos) automatically. Let me know if you’d like assistance with Task Scheduler or additional automation steps!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$source = "Z:\DCIM\100NIKON" # Replace with your camera's folder path | |
$destination = "C:\SyncedVideos" # Local folder to sync videos | |
# Ensure destination exists | |
if (!(Test-Path -Path $destination)) { | |
New-Item -ItemType Directory -Path $destination | |
} | |
# Set up the FileSystemWatcher | |
$watcher = New-Object System.IO.FileSystemWatcher | |
$watcher.Path = $source | |
$watcher.Filter = "*.mp4" # Adjust to match video file type | |
$watcher.IncludeSubdirectories = $true | |
$watcher.EnableRaisingEvents = $true | |
# Define the action for new files | |
$action = { | |
$path = $Event.SourceEventArgs.FullPath | |
$dest = $path.Replace($source, $destination) | |
$destDir = Split-Path $dest | |
if (!(Test-Path -Path $destDir)) { | |
New-Item -ItemType Directory -Path $destDir -Force | |
} | |
Copy-Item -Path $path -Destination $dest -Force | |
Write-Output "File copied: $path -> $dest" | |
} | |
# Register the event | |
Register-ObjectEvent $watcher Created -Action $action | |
# Keep the script running | |
Write-Output "Watching for new files..." | |
while ($true) { Start-Sleep -Seconds 10 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment