From 6ceb8a9e931e525fc67bca2d7f65372178da0d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20M=C3=A4ki?= Date: Thu, 28 Dec 2023 14:44:14 +0200 Subject: [PATCH] Add Copy-Floppy.ps1 --- Copy-Floppy.ps1 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 Copy-Floppy.ps1 diff --git a/Copy-Floppy.ps1 b/Copy-Floppy.ps1 new file mode 100755 index 0000000..b98244e --- /dev/null +++ b/Copy-Floppy.ps1 @@ -0,0 +1,34 @@ +. ".\utils.ps1" + +$FloppyFolder = "./floppy" +if (-not (Test-Path "${FloppyFolder}")) { + New-Item -Path "${FloppyFolder}" -ItemType "directory" +} + +while ($true) { + while ($true) { + $Name = Read-Host "Please insert a new floppy and give a name for it" + $FloppyPath = "${FloppyFolder}\${Name}" + if (Test-Path "${FloppyPath}") { + Show-Output "This folder already exists. Please use another name." + } elseif (Test-Path "${Name}" -IsValid) { + break + } else { + Show-Output "Invalid name. Please don't use special characters etc." + } + } + + Show-Output "Copying the floppy." + Copy-Item -Path "A:\" -Destination "${FloppyPath}" -Recurse + if (-not $?) { + Show-Output "Copying the floppy failed. Please check the output folder to see which files were copied." + continue + } + + # $Format = Get-YesNo -Question "Floppy copied. Do you want to format the floppy?" + # if ($Format) { + # Format-Volume -DriveLetter "A" -FileSystem "FAT" -Full -Force + # } + # Show-Output "Floppy formatted. Please remove the floppy." + Show-Output "Floppy copied. Please remove the floppy." +}