3.2 KiB
UNC File Watcher
This project is a Go-based local web console for watching files in UNC paths and copying or moving them to local directories.
After build, the program is a single exe. The target machine does not need Go installed.
Features
The program supports two rule types at the same time:
-
Archive rule Watches
.tar.gzCopies or moves files to azipdirectory Skips when thezipdirectory already has a file with the same name Skips when theunzipdirectory already has an extracted folder with the same name Inmovemode, if the existing archive or extracted folder is verified as the same content, the source file is removed -
Generic file rule Watches other file types by extension list Only needs
UNC source path + local target pathDoes not useunzipSupports two dedupe modes Inmovemode, duplicate files are removed from the source only after hash verification
Generic File Dedupe
The generic file rule supports these dedupe modes:
-
Same name and same sizeThis is the default mode If the target directory already has a file with the same name and the same size, the file is skipped If the target directory already has a file with the same name but a different size, it is treated as a conflict and skipped without overwrite Inmovemode, the program still verifies SHA-256 before deleting the source duplicate -
Same name and same hashWhen the target directory already has a file with the same name, the program computes SHA-256 for source and target If the hashes match, the file is skipped If the hashes do not match, it is treated as a conflict and skipped without overwrite
Stable File Detection
To avoid processing a file while another service is still writing it in the UNC path, the program checks both conditions:
size + modified timestay unchanged across multiple scans- the last modified time is older than
stable_for
Suggested starting values:
scan interval: 15s
stable_for: 1m
stable_scans: 3
Build
go build -o unc-file-watcher.exe .
Run
.\unc-file-watcher.exe
Default listen address:
http://127.0.0.1:18080
To change the port:
.\unc-file-watcher.exe -listen 127.0.0.1:19090
Web UI Settings
Archive Rule
- Enable archive rule
- Archive UNC source path
- Zip path
- Unzip path
Generic File Rule
- Enable generic file rule
- Generic file UNC source path
- Local target path
- Extension list, for example
.csv,.txt,.pdf - Dedupe mode
Shared Settings
- Scan interval
- Stable duration
- Stable scan count
- Transfer mode:
copyormove - Recursive scan
Local Settings File
The web UI saves settings automatically next to the executable:
unc-file-watcher-settings.json
When you open the page again, the last saved settings are loaded automatically.
Runtime Notes
- In
copymode, source files remain in the UNC path - In
movemode, the program copies first and then removes the source file - In
movemode, if a duplicate is detected, the source file is removed only after hash/content verification succeeds - The generic file rule never overwrites an existing target file when a conflict is detected
- The archive rule only handles
.tar.gz