Last active
August 21, 2023 12:02
-
-
Save MrAMS/eb872616f191032e7738074981a451e3 to your computer and use it in GitHub Desktop.
This file contains 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 | |
if [ -z "$2" ]; then | |
echo "Usage: <dir_name> <url>" | |
echo " <url> support printf format and continue to download until fail" | |
exit 1 | |
fi | |
mkdir "$1" | |
cd "$1" | |
for ((i=1; ; i++)); do | |
url=$(printf $2 ${i}) | |
if [ -f $(basename "${url}") ]; then | |
continue | |
fi | |
sleep 1 | |
wget "${url}" | |
# Check the exit code of wget | |
if [ $? -ne 0 ]; then | |
echo "Download failed. Bye." | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example:
./download_url_squ.sh "けもみみメイドといちゃいちゃする本3さつ目" https://img3.qy0.ru/data/1216/35/%03d.jpg