Last active
November 3, 2023 05:20
-
-
Save punkrocker178/05f19b5c1a08597cb7022d1e10f64664 to your computer and use it in GitHub Desktop.
Download images from resource servers such as wp-content.
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 | |
# Link to download resource as first argument | |
base_url=$1 | |
# end | |
# Number to stop the incrementing id | |
end_id=$2 | |
# starting id, will default to 1 if empty | |
start_id=$3 | |
# output file will be downloaded here | |
download_directory=$4 | |
if [ $# -eq 0 ] | |
then | |
echo "No arguments supplied" | |
fi | |
if [[ -z $start_id ]]; then | |
start = 1 | |
fi | |
for i in $(seq $start_id $end_id) ; do | |
# Default id format is 0001, change to your desired format | |
_U=`printf $base_url"%04d".jpg $i` | |
echo "Downloading" $_U | |
wget -a log$limit -P $download_directory --server-response $_U | |
done | |
echo "Done" |
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
./download-img.sh $base_url_1 ${end_id} ${start_id} your_directory & | |
./download-img.sh $base_url_2 ${end_id} ${start_id} your_directory & | |
./download-img.sh $base_url_3 ${end_id} ${start_id} your_directory && fg |
If you want to download in multiple processes then edit multiple-download.sh
to fit your needs
Script reference from this guide
This script only used for downloading files with incremental ID,
Hashed ID will not work
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not a multithreaded solution.