1

I'm on macOS and I downloaded unar to decompress encrypted rar files. It works fine for individual files but I can't get it to work with a wildcard for multiple files.

I have a list of rar files which have filenames from 01...10 and the unar executable in the current folder.

myArchive01.rar
myArchive02.rar
..
myArchive10.rar

It works great for one single file:

$ ./unar -p myPassword myArchive01.rar
myArchive01.rar: RAR
  myText.txt  (1000 B)... OK.
Successfully extracted to "./myText.txt".

But I don't get it to work with a bunch of files:

$ ./unar -p myPassword myArchive*.rar
myArchive01.rar: RAR
No files extracted.

I could of course use the built in batch functions in macOS, but I wanted to know how unar does this by it's own

$ for i in {1..10}; do ./unar -p myPassword myArchive${i}.rar; done

Can anybody help out?

2 Answers 2

1

It doesn't seem to take wildcards indeed, only a list of files.

You can use the find -exec command to run the unar command on each file found:

find . -name "*.rar" -exec unar {} \;
0

You could use find and exec to extract the files sequentially.

Eg. find ./ -name myArchive* -exec unar -p myPassword {} \;


What that does is uses find to find all files matching the name pattern, and then execute the command after exec for each found result.

You must log in to answer this question.

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