
in
Sometimes, when marking practical assessments, you might want to return the assessment folders to your learners. That means having to zip up every assessment as it contains many sub-folders and files. Here is a time-saving Powershell script which will automatically zip up every folder in a main folder. Copy the code below into a plain text file. Save the file as Zip.ps1 in the same folder as your learner folders. Run the script by right-clicking on it and select “Run with Powershell”. Hope that helps. Enjoy!
$sourceDirectory = (Get-Location).Path
# Get all folders in the source directory
$folders = Get-ChildItem -Path $sourceDirectory -Directory
foreach ($folder in $folders) {
$folderPath = $folder.FullName
$zipFileName = "$($folder.Name).zip"
$zipFilePath = Join-Path -Path $sourceDirectory -ChildPath $zipFileName
# Create a new zip file for the folder
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($folderPath, $zipFilePath)
Write-Host "Created zip file: $zipFileName"
}