script for unzipping multiple folders in single command
# Set the path where zip files are located
$path = "C:\Users\mschi\Desktop\youtube\unzip"
# Validate the path
if (-Not (Test-Path $path)) {
Write-Host "Invalid path! Please check and try again."
exit
}
# Get all zip files in the path
$zipFiles = Get-ChildItem -Path $path -Filter *.zip
# Check if there are any zip files
if ($zipFiles.Count -eq 0) {
Write-Host "No zip files found in: $path"
exit
}
# Loop through and unzip each zip file
foreach ($zipFile in $zipFiles) {
$zipFilePath = $zipFile.FullName
$destinationFolder = Join-Path $path ($zipFile.BaseName)
# Create the destination folder if it doesn't exist
if (-Not (Test-Path $destinationFolder)) {
New-Item -ItemType Directory -Path $destinationFolder | Out-Null
}
# Unzip the contents
try {
Expand-Archive -Path $zipFilePath -DestinationPath $destinationFolder -Force
Write-Host "Unzipped: $zipFilePath -> $destinationFolder"
}
catch {
Write-Host "Failed to unzip: $zipFilePath"
}
}
Write-Host ""
Write-Host "Unzipping process completed."