Created
February 18, 2026 03:38
-
-
Save rufflabs/de3f606a2b104f0fb9188d5cac22f4fc to your computer and use it in GitHub Desktop.
Copies files to a floppy disk and waits for another disk to be inserted.
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 = ".\badge" | |
| $Files = Get-ChildItem -Path $Source | |
| $floppyCount = 0 | |
| $totalBytes = 0 | |
| $totalSizePerFloppy = ($Files | Measure-Object -Property Length -Sum).Sum | |
| $Delay = 10 | |
| $Start = Get-Date | |
| function Countdown($Delay) { | |
| for ($i = $Delay; $i -ge 1; $i--) { | |
| Write-Host -NoNewline "`rContinuing in $i seconds " | |
| Start-Sleep -Seconds 1 | |
| } | |
| Write-Host "`rContinuing now! " | |
| } | |
| function Pause-Or-Wait { | |
| param( | |
| [int]$TimeoutSeconds = 10 | |
| ) | |
| Write-Host "" | |
| Write-Host -NoNewline "`rPress 'p' to pause or wait $TimeoutSeconds seconds to continue..." -ForegroundColor Yellow | |
| $stopTime = (Get-Date).AddSeconds($TimeoutSeconds) | |
| while ((Get-Date) -lt $stopTime) { | |
| if ([console]::KeyAvailable) { | |
| $key = [console]::ReadKey($true) | |
| if ($key.KeyChar -eq 'p' -or $key.KeyChar -eq 'P') { | |
| Write-Host "Paused. Press any key to resume..." -ForegroundColor Yellow | |
| [console]::ReadKey($true) | Out-Null | |
| Write-Host "Resuming..." -ForegroundColor Green | |
| return | |
| } | |
| else { | |
| break | |
| } | |
| } | |
| Start-Sleep -Seconds 1 | |
| $TimeoutSeconds-- | |
| Write-Host -NoNewline "`rPress 'p' to pause or wait $($TimeoutSeconds) seconds to continue... " -ForegroundColor Yellow | |
| } | |
| Write-Host "`nContinuing..." -ForegroundColor Green | |
| } | |
| Write-Output "Preparing to load $($Files.Count) files ($([math]::Round($totalSizePerFloppy/1KB, 2)) KB) per floppy." | |
| $FloppyDrive = Get-PSDrive -Name "A" -ErrorAction SilentlyContinue | |
| if ($FloppyDrive) { | |
| try { | |
| while ($true) { | |
| try { | |
| Write-Host "`nChecking floppy drive..." -ForegroundColor Cyan | |
| $Destination = Get-Item "A:\" -ErrorAction Stop | |
| if ($Destination) { | |
| $DestinationFiles = Get-ChildItem "A:\" -ErrorAction SilentlyContinue | |
| if ($DestinationFiles) { | |
| if ($DestinationFiles.Name -contains "davinci.pyc") { | |
| Write-Host "Disk not ejected." -ForegroundColor Green | |
| Read-Host -Prompt "Press enter when ready to continue" | |
| continue | |
| } | |
| else { | |
| Write-Warning "Floppy disk not empty! Deleting files..." | |
| Write-Host "Existing files will be deleted :" -ForegroundColor Yellow | |
| Get-ChildItem -Path "A:\" | Remove-Item -Force -Recurse | |
| } | |
| } | |
| } | |
| Write-Host "Copying $($Files.Count) files ($([math]::Round($totalSizePerFloppy/1KB, 2)) KB)..." -ForegroundColor Cyan | |
| $Files | ForEach-Object { | |
| Copy-Item -Path $_.FullName -Destination "A:\" -ErrorAction Stop | |
| } | |
| $floppyCount++ | |
| $totalBytes += $totalSizePerFloppy | |
| Write-Host "Files copied successfully. Please insert another disk." -ForegroundColor Green | |
| Get-ChildItem -Path "A:\" | |
| [System.Console]::Beep() | |
| Pause-Or-Wait -TimeoutSeconds 10 | |
| } | |
| catch { | |
| Write-Output "Error: $_" | |
| Write-Host "Waiting $($Delay) seconds before retry..." -ForegroundColor Yellow | |
| Countdown($Delay) | |
| } | |
| } | |
| } | |
| finally { | |
| $End = Get-Date | |
| $Elapsed = $End - $Start | |
| Write-Host "`n=== OPERATION STOPPED ===" -ForegroundColor Red | |
| Write-Host ("Elapsed: {0:hh\:mm\:ss} (hh:mm:ss)" -f $Elapsed) -ForegroundColor Cyan | |
| Write-Host "Total floppies used: $floppyCount" -ForegroundColor Cyan | |
| Write-Host "Total data copied: $totalBytes bytes ($([math]::Round($totalBytes/1KB, 2)) KB)" -ForegroundColor Cyan | |
| } | |
| } | |
| else { | |
| Write-Output "Error: No floppy drive is detected." | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment