Created
March 1, 2017 14:31
-
-
Save Tony3-sec/a49ce88689f44ec0bf06b0aacf989cd9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| ## Script to bulk download the file from URL. | |
| ## If filename duplicates, append a counter to the filename. | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $0 [Needs file as arg]" | |
| exit 1 | |
| fi | |
| URL_list=$1 | |
| if [ ! -e $URL_list ]; then | |
| echo "$URL_list does not exist." | |
| exit 2 | |
| fi | |
| count=0 | |
| echo "Fetching files....." | |
| for url in $(cat $URL_list) | |
| do | |
| filename=$(basename "$url") | |
| if [ -e $filename ]; then | |
| count=$(($count + 1)) | |
| curl -s $url -o $filename$count | |
| else | |
| curl -s $url -O | |
| fi | |
| done | |
| echo "Complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment