41 lines
1.6 KiB
PowerShell
41 lines
1.6 KiB
PowerShell
# sync-vizion-repos.ps1
|
|
# Syncs all repos from VizionAI-Trading-Repo into Experts\Shared Projects via NTFS junctions.
|
|
# Run this whenever a new repo is cloned into VizionAI-Trading-Repo.
|
|
#
|
|
# Usage: powershell -ExecutionPolicy Bypass -File sync-vizion-repos.ps1
|
|
|
|
$base = "C:\Users\sahrk\AppData\Roaming\MetaQuotes\Terminal\FB9A56D617EDDDFE29EE54EBEFFE96C1\MQL5"
|
|
$repoRoot = "$base\Shared Projects\VizionAI-Trading\VizionAI-Trading-Repo"
|
|
$linkRoot = "$base\Experts\Shared Projects"
|
|
|
|
# Ensure junction target directory exists
|
|
if (-not (Test-Path $linkRoot)) {
|
|
New-Item -ItemType Directory -Path $linkRoot -Force | Out-Null
|
|
Write-Host "Created: $linkRoot"
|
|
}
|
|
|
|
# For each repo folder in VizionAI-Trading-Repo, create a junction in Experts\Shared Projects
|
|
$repos = Get-ChildItem -Path $repoRoot -Directory
|
|
foreach ($repo in $repos) {
|
|
$linkPath = "$linkRoot\$($repo.Name)"
|
|
$targetPath = $repo.FullName
|
|
|
|
if (Test-Path $linkPath) {
|
|
$item = Get-Item $linkPath -Force
|
|
if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) {
|
|
Write-Host "Junction already exists: $linkPath"
|
|
continue
|
|
} else {
|
|
# Regular directory — remove it before creating junction
|
|
Remove-Item -Path $linkPath -Recurse -Force
|
|
Write-Host "Removed stale directory: $linkPath"
|
|
}
|
|
}
|
|
|
|
cmd /c "mklink /J `"$linkPath`" `"$targetPath`"" | Out-Null
|
|
Write-Host "Created junction: $linkPath -> $targetPath"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "Sync complete. Junctions in Experts\Shared Projects:"
|
|
Get-ChildItem $linkRoot | Select-Object Name, Attributes | Format-Table -AutoSize
|