Skip to content

Instantly share code, notes, and snippets.

@elisim
Last active May 3, 2021 13:27
Show Gist options
  • Save elisim/fa0347b9fcaee402bf8071c0642a4383 to your computer and use it in GitHub Desktop.
Save elisim/fa0347b9fcaee402bf8071c0642a4383 to your computer and use it in GitHub Desktop.
Powershell script to unrar RAR files in a directory a given destination
# # This script will unrar the RARs in $src to $dest. Based on:
# https://serverfault.com/questions/356184/powershell-unrar-with-wildcard/356208?newreg=44a1363382a04e7a95a915434574dec2
param (
[Parameter(Mandatory=$true)][string]$src,
[Parameter(Mandatory=$true)][string]$dest
)
$files = @()
Get-ChildItem $src -Recurse -Filter "*.rar" | % {
# Recurse through all subfolders looking for .rar files only.
$files = $files + $_.FullName
}
foreach ($f in $files) {
# UnRAR the files. -y responds Yes to any queries UnRAR may have.
C:\"Program Files"\WinRAR\unrar x -y $f $dest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment