1

My question is simple. Is it possible to unrar multiple rar files in diffrent directorys. Like

- Folder 1
--Folder 1.1
---File1.rar
--Folder 1.2
---File2.rar

and that the file will be extracted in the same directory were the .rar files are located. And after that the .rar and .r01 should be removed.

find . -type f -name '*.rar' -print0 | 
    while IFS= read -r -d '' file; do
        dir=$(dirname "$file")
        rar=$(basename "$file")
        cd "$dir"
        unrar e "$rar" && rm "$rar"
        cd -
    done

I found this here but I don't know how I could add that the .r00 files get deleted too.

Sadly unrar -r extract everything to the folder where i run the command. I hope somebody could help me.

1 Answer 1

0

I don't use unrar, but if you use 7z with the -x option, files extracted from the original .RAR archive will go into their respective subdirectories.

1
  • unrar has an x parameter too, whilst I have not tested for directories, I needed this rather than unrar e for file names with output filenames spaces in them. else is parsed it into seperate words and failed.
    – pierrely
    Jun 23, 2022 at 5:46

You must log in to answer this question.

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