Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- folder=$1
- res=$2
- list=$folder/list.txt
- touch "$list"
- for i in $(seq -f "%03g" 0 599); do
- while [ ! -f "$folder/$i.jpg" ]; do
- current=$(curl -si https://source.unsplash.com/random/$res | grep 'Location: ' | cut -d ' ' -f 2 | tr -d '[:space:]')
- found=false
- echo checking list for $current...
- while IFS= read -r line; do
- if [ "$line" == "$current" ]; then
- found=true
- break
- fi
- done < "$list"
- if [ "$found" == "false" ]; then
- echo file not found, downloading...
- curl -Lf -o "$folder/$i.jpg" $current && echo $current >> $list
- else
- echo file found, skipping...
- fi
- sleep 4
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement