Skip to content

Instantly share code, notes, and snippets.

@punkrocker178
Last active November 3, 2023 05:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punkrocker178/05f19b5c1a08597cb7022d1e10f64664 to your computer and use it in GitHub Desktop.
Save punkrocker178/05f19b5c1a08597cb7022d1e10f64664 to your computer and use it in GitHub Desktop.
Download images from resource servers such as wp-content.
#!/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"
./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
@punkrocker178
Copy link
Author

This is not a multithreaded solution.

@punkrocker178
Copy link
Author

If you want to download in multiple processes then edit multiple-download.sh to fit your needs

Script reference from this guide

@punkrocker178
Copy link
Author

punkrocker178 commented Oct 20, 2023

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