I have directories with hundreds of RAR files. Currently I use Powershell 2.0 with a script that utilizes WinRAR's RAR utility to decompress the files. The issue is that a small number of the files end up being encrypted, which pauses the script and requires interaction. Is there any way to do one of the following:
- Identify the encrypted files before trying to decompress
- Entirely ignore the encrypted files
- Automate an incorrect (or correct) password that will attempt to open the file, but just skip it if incorrect.
NOTE: Some of the compressed files encrypt just file contents, whereas others encrypt file name and file contents.
Relevent Code:
$files = Get-ChildItem
foreach($file in $files)
{
if($file.Attributes -eq "Archive")
{
$folder = $file.basename
rar x $file $folder\ -y
}
}