One command, no script is needed, great time saver
Unpack (decompress) all files in multiple subdirectories, such as for example torrents with whole TV series with each episode in its own directory and each directory containing a lot of compressed files
/TV-show/
/TV-show/Episode.Name.S01E01/episode.name.01.r01
/TV-show/Episode.Name.S01E01/episode.name.01.r02
…
…
/TV-show/Episode.Name.S01E02/episode.name.02.rar
/TV-show/Episode.Name.S01E02/episode.name.02.r01
/TV-show/Episode.Name.S01E02/episode.name.02.r02
…
…
/TV-show/Episode.Name.S01E02/episode.name.02.rar
TV-show/Episode.Name.S01E03/episode.name.03.r01
/TV-show/Episode.Name.S01E03/episode.name.03.r02
…
…
/TV-show/Episode.Name.S01E03/episode.name.03.rar
Change to the TV-show directory and use unrar command:
$ cd /home/username/Videos/TV-show
$ unrar e -r *.rar
In your terminal, you should see a lot of lines like this:
Extracting from Episode.Name.S01E0X/episode.name.0X.rY
… Episode.Name.0X.avi OK
All OK
And done!
To understand this command, unrar is command line application to decompress .rar files, e is command to extract files to current directory, -r is switch to recurse subdirectories.
TIP
You can run this command on any number of subdirectories, even whole Downloads folder, if you want to unrar everything and some archives are already unrar-ed, consider option switch -o- which is do not overwrite existing files, makes it faster and you do not have to confirm anything manually. For more information $ man unrar.
$ cd /home/username/Videos
$ unrar e -r -o- *.rar
This will extract all archives in any subdirectory inside Videos directory, if archive is already extracted, it will ignore it. Files will be extracted to the directory that you are in now, in this case /home/username/Videos.
To extract archives in a directory and it’s subdirectories to other specified directory, use:
$ unrar e -r -o- /home/username/source/directory/*.rar /home/username/copy/extracted/to
If you do not specify the path, you may end up with extracted files in your home dir or whatever path you run these commands from.