Last active
August 29, 2015 13:56
-
-
Save RobinDavid/9171780 to your computer and use it in GitHub Desktop.
Bash script to download all zip or rar files from a website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
lien="$1" | |
dossier="" | |
exclure="$2" | |
wget -nv -nc -nd -X $exclure -r -linf -A zip,rar $lien | |
for file in `ls` do | |
if ( expr "$file" : .*rar$ ) > /dev/null | |
then | |
echo "Extraction de : $file" | |
dossier=`basename $file .rar` | |
mkdir $dossier unrar x $file $dossier > /dev/null | |
if (( $? != 0 )) | |
then | |
echo "$file" >> error.log | |
else rm $file echo $lien/$file >> sup.log | |
fi | |
elif ( expr "$file" : .*zip$ ) > /dev/null | |
then | |
echo "Extraction de : $file" | |
dossier=`basename $file .zip` | |
mkdir $dossier unzip $file -d $dossier> /dev/null | |
if (( $? != 0 )) | |
then | |
echo "$file" >> error.log | |
else | |
rm $file echo $lien/$file >> sup.log | |
fi | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment