0

I am looking for a command in the windows terminal that allows me to unrar all the files from a folder. Precisely I want to replicate this bash command on windows

find . -name "*.rar" -exec unrar x -o+ {} \;

thank u

3 Answers3

0

Well Powershell would be a great option, something like this should do the trick:

Get-ChildItem -File *.rar | Foreach {unrar x -o+ $_.fullname}
RS Finance
  • 224
  • 1
  • 9
0

I would prefer RS Finance's answer: a power shell provides an easy and clean solution. However, if that's not an option, you may achieve the same with command prompt like this (first cd to the correct directory),

for %i in (*.rar) do "C:\Program Files\7-Zip\7z.exe" e "%i"

I use 7z as my zip program. You just have to replace the path to whatever you use. If you have the path stored in you environment path, "7z.exe" without the absolute path may be enough.

Note that,

Wololo
  • 1,249
  • 1
  • 13
  • 25
  • thank you. That is what i wanted. I needed the normal shell because i wanted to execute it from a python script – Ángel Delgado Panadero Jul 31 '18 at 08:03
  • @ÁngelDelgadoPanadero : If you're using python, I would strongly recommend you to use the `zipfile` module, instead of calling batch commands. Have a look at this one: https://stackoverflow.com/questions/3451111/unzipping-files-in-python – Wololo Jul 31 '18 at 10:51
0

It's better to use UnRAR.exe supplied with WinRAR Trial. This console utility is freeware, and definitely supports all RAR format versions

e.g.

for %i in (*.rar) do "C:\Program Files (x86)\WinRAR\UnRAR.exe" x "%i"

to extract all archives contents with relative paths or

for %i in (*.rar) do "C:\Program Files (x86)\WinRAR\UnRAR.exe" e "%i"

to extract everything to the same folder