001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051
|
#!/bin/bash
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
if [ ! $1 ]; then
echo "Missing source as \$1"
exit 1
fi
if [ ! $2 ]; then
echo "Missing target as \$2"
exit 2
fi
if [ ! -d $1 ]; then
echo "$1 doesn't exist"
exit 3
fi
if [ ! -d $2 ]; then
mkdir -p $2
if [ "$?" -ne "0" ]; then
exit 4
fi
fi
source=$1
target=$2
cd "$source"
find . -type d |cut -d/ -f 2- |while read dir; do
if [ ! -d "$target/$dir" ]; then
echo -n "Working in $dir "
cd "$source/$dir"
mkdir "$target/$dir"
find . -maxdepth 1 -mindepth 1 -type f ! -name "*.r??" |cut -d/ -f 2 |while read file; do
echo -n "."
cp "$file" "$target/$dir/$file"
done
find . -maxdepth 1 -mindepth 1 -type f -name "*.rar" |cut -d/ -f 2 |sort |head -n 1 |while read rarfile; do
echo -n "+"
unrar e -inul "$rarfile" "$target/$dir/"
done
echo " done"
fi
done
|