diff --git a/UpdateSequences.bat b/UpdateSequences.bat index 61a8143..e58d238 100644 --- a/UpdateSequences.bat +++ b/UpdateSequences.bat @@ -8,4 +8,5 @@ set "rc=%errorlevel%" echo PowerShell exited with RC=%rc% echo @"_CURRENT\_UpdateSequences.log" echo Done. +pause >nul exit /b %rc% \ No newline at end of file diff --git a/UpdateSequences.ps1 b/UpdateSequences.ps1 index 4df8706..83c8fc2 100644 --- a/UpdateSequences.ps1 +++ b/UpdateSequences.ps1 @@ -174,6 +174,15 @@ try { $srcFull = $parts[1] $seqName = $parts[2] $dstAbs = Join-Path $currentDir $seqName + if (Test-Path -LiteralPath $dstAbs) { + "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] WIPE: removing existing destination '$dstAbs'" | Add-Content -LiteralPath $logFile + try { + Remove-Item -LiteralPath $dstAbs -Recurse -Force -ErrorAction Stop + } + catch { + "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] WIPE ERROR: $($_.Exception.Message)" | Add-Content -LiteralPath $logFile + } + } if (-not (Test-Path -LiteralPath $dstAbs)) { New-Item -ItemType Directory -Path $dstAbs -Force | Out-Null } "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] Mirror: '$srcFull' -> '$dstAbs'" | Add-Content -LiteralPath $logFile $robocopyArgs = @(