Identify ENCRYPTED compressed files at the command line
Posted
by
viking
on Super User
See other posts from Super User
or by viking
Published on 2011-06-22T19:03:04Z
Indexed on
2011/06/27
0:24 UTC
Read the original article
Hit count: 550
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
}
}
© Super User or respective owner