Hi again.
I believe you are having issues with spaces in both paths and filenames.
In post#3 there's a explanation on how to avoid any problem with spaces, and other special characters. This is important in the long run because you have to consider that some torrents are not originated in English speaking languages, so may even contain non ASCII characters.
The safest approach is to use a while<<find structure like this:
Code:
while IFS= read -d $'\0' -r rarfile
do
echo "Unpacking in directory: "`dirname $rarfile`
unrar e -v "$rarfile" `dirname "$rarfile"`
done< <(find "$1" -type f -regextype posix-extended -iregex '.*\.(rar|r01|001|01)' -print0)
Although, I recommend taking it a little but further and use:
Code:
while IFS= read -d $'\0' -r rarfile
do
unpack_dir=""${rarfile%/*}""
echo "Unpacking in directory: $unpack_dir"
unrar e -v "$rarfile" "$unpack_dir"
done< <(find "$1" -type f -regextype posix-extended -iregex '.*\.(rar|r01|001|01)' -print0)
I hope that helps. Let us know how it goes.
Regards.
P.S.: there could be a minor issue when in a single directory there's a both a 'something.rar' file, and another file called 'something.r01'. The current code would extract the content twice. I don't know how frequent that would be, but let us know if you want to tackle those cases.
Bookmarks