So after digging around for a day or so I have found not much information about powershell and extracting files with winrar's command line.
My difficulty lies with the actual execution of the arguments and command line.
Here is my simple code so far:
$WinRar = "C:\Program Files\WinRAR\winrar.exe"
#filter through files looking for zip files.
$path = get-ChildItem -filter "*.zip" -path A:\testfolder\ -recurse
#test to see if it is actually filtering and showing correct results:
write-host = $path | format-table directory
#arguments :: x (extract) y(presume yes) r(recurse subdir)
&$WinRar x -y -r "$path" A:\Testfolder\
read-host "press to exit"
I'm pretty new to powershell and seem to be catching on pretty quick but I'm assuming I have got this completely wrong as the code executes but it doesn't extract. So I guess it errors out somewhere with the command line and I cant see what it is doing.
Are they any suggestions or tips that can point me in the right direction?
I have tried many variations of the $winrar command with no luck except for the part if I replace $path with the actual file path it works.. which isn't what I need :P
You can use simple foreach method for this:
$Zips = Get-ChildItem -filter "*.zip" -path A:\testfolder\ -Recurse
$Destination = 'C:\Extracted'
$WinRar = "C:\Program Files\WinRAR\winrar.exe"
foreach ($zip in $Zips)
{
&$Winrar x $zip.FullName $Destination
Get-Process winrar | Wait-Process
}
If you want multiple WinRAR processes running together, remove the Get-Process
line