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



Possibly Related Threads…
Thread Author Replies Views Last Post
  How to disable/enable GUI on boot in Ubuntu 20.04 Focal Fossa Linux Desktop SickProdigy 0 1,281 03-30-2022, 12:57 AM
Last Post: SickProdigy
  How to install Node.js 16 on Ubuntu 20.04 LTS SickProdigy 0 1,105 03-23-2022, 08:13 PM
Last Post: SickProdigy
  Fedora - Recover your files from Btrfs snapshots xSicKxBot 0 1,079 10-05-2020, 04:17 PM
Last Post: xSicKxBot
  (Ubuntu) 7 Days to Die: How to Install Plugins/Mods for your Dedicated Server SickProdigy 0 1,178 03-29-2020, 10:46 PM
Last Post: SickProdigy
  Fedora - Firefox GNOME search provider xSicKxBot 0 967 12-20-2019, 10:45 PM
Last Post: xSicKxBot
  BT Adopts Ubuntu OpenStack xSicKxBot 0 1,180 07-26-2019, 04:06 PM
Last Post: xSicKxBot
  How to Change User Password in Ubuntu xSicKxBot 0 1,114 04-26-2019, 06:10 AM
Last Post: xSicKxBot
  How to Install LDAP Account Manager on Ubuntu Server 18.04 xSicKxBot 0 1,089 04-01-2019, 12:34 AM
Last Post: xSicKxBot
  How to Install NTP Server and Client(s) on Ubuntu 18.04 LTS xSicKxBot 0 1,084 03-29-2019, 06:26 AM
Last Post: xSicKxBot
  How to Install OpenLDAP on Ubuntu Server 18.04 xSicKxBot 0 1,173 03-22-2019, 01:01 PM
Last Post: xSicKxBot

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016