Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to recursively search for RAR files and extract from directory (Ubuntu)

#1
First what I'd do is right click in the directory, open a terminal from it. Then just paste this command and you will see all rar files be expanded to the current directory.

Code:
find . -name '*.rar' -exec unrar e {} \; -exec rm {} \;

Code:
-exec rm {} \;

will only be run to remove the .rar file if the unrar-ing succeeds
(-exec unrar e {} \;)

i.e. unrar returns with exit status 0.

You can also do this using bash, using globstar option to recursively match glob pattern (*.rar), and rm each file if unrar-ing is successful:

Code:
shopt -s globstar
for f in **/*.rar; do
    unrar e "$f" && rm "$f"
done

Now I'm using Ubuntu 16.04 ltz as a home server. Use this command a lot with torrenting ;)
[Image: 8OHl5AB.png]
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016