Reputation: 411
I have a lot of rar archives structured in individual folders and would like to script unpacking them all.
I'm having trouble figuring out how it should be done and need some help.
#!/bin/bash
## For all inodes
for i in pwd; do
## If it's a directory
if [ -d "$i" ] then
cd $i
## Find ".rar" file
for [f in *.rar]; do
./bin/unrar x "$f" # Run unrar command on filename
cd ..
done
done
done
I am not familiar with bash scripting and I assume the code is wrong more than once. But I guess this should be the basic structure
Upvotes: 15
Views: 22087
Reputation: 3367
You don't need a script.
find . -name "*.rar" -exec unrar x {} \;
Additionally, you could pass the results of find to unrar
command.
find . -name "*.rar" | xargs unrar x
Upvotes: 10