0

I have an RAR archive, and I want to extract all files with a three-digit number as an extension. I tried with Winrar but it does not accept REGular EXpression:

winrar.exe e -y pinetinf pinet.[0-9*] .      // pattern: does not work
winrar.exe e -y pinetinf pinet.222 .         // single file name: WORK

How can I extract all the files whose names have a three-digit extension?

2
  • I'm afraid you can't.
    – Toto
    Commented Aug 5, 2018 at 8:30
  • I think you can use list option of rar (or you can use 7-zip that can also extract files form rar) then bypass result to some filter (some external tool that will extract filenames you need without PITA) then extract files using include options of archiver together with extract option.
    – Alex
    Commented Aug 5, 2018 at 17:28

1 Answer 1

0

You can't do that using WinRAR only but you can call Powershell to help you out with the filtering.

List the files from the archive and pipe the output to a for loop to extract the needed ones in a Powershell console.

& 'UnRAR.exe' 'lb' '.\file.rar' | ForEach-Object { If($_ -like '*.[0-9][0-9][0-9]') { & 'UnRAR.exe' 'e' '.\file.rar' $_ } }

Alternatively you can create a list file and run unrar.exe only once to extract the files (maybe it's a bit faster to do it this way if you have loads of files).

& 'UnRAR.exe' 'lb' '.\file.rar' | ForEach-Object { If($_ -like '*.[0-9][0-9][0-9]') { Out-File '.\files.list' -InputObject $_ -Append } } | & 'UnRAR.exe' 'e' '.\file.rar' '-n@.\files.list'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .