Skip to content

Instantly share code, notes, and snippets.

@MrAMS
Last active August 21, 2023 12:02
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 MrAMS/eb872616f191032e7738074981a451e3 to your computer and use it in GitHub Desktop.
Save MrAMS/eb872616f191032e7738074981a451e3 to your computer and use it in GitHub Desktop.
#!/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
@MrAMS
Copy link
Author

MrAMS commented Aug 21, 2023

For example:

./download_url_squ.sh "けもみみメイドといちゃいちゃする本3さつ目" https://img3.qy0.ru/data/1216/35/%03d.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment