Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinDavid/9171780 to your computer and use it in GitHub Desktop.
Save RobinDavid/9171780 to your computer and use it in GitHub Desktop.
Bash script to download all zip or rar files from a website
#!/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