Skip to content

Instantly share code, notes, and snippets.

@suqingdong
Last active January 5, 2022 08:40
Show Gist options
  • Save suqingdong/3fdefc2d781f6d4423167ce7273c8fc4 to your computer and use it in GitHub Desktop.
Save suqingdong/3fdefc2d781f6d4423167ce7273c8fc4 to your computer and use it in GitHub Desktop.
figshare.com数据集批量下载
#!/bin/bash
set -eo pipefail
if [ ! $1 ];then
echo "usage: $0 URL/ID [OUT_DIR]"
echo "example: $0 12623960"
exit 1
fi
url=$1
url=https://figshare.com/articles/dataset/genome_fasta_sequence_and_annotation_files/${url##*/}
if [ $2 ];then
out=$2
else
out=${url##*/}
fi
mkdir -p $out
echo url: $url
echo outdir: $out
curl -s $url | grep -oP 'https://figshare.com/ndownloader/files/\d+' | sort -u > url.list
while read url;do
name=$(curl -s -I $url | grep content-disposition | cut -d = -f 2 | sed 's#\r##g')
echo "wget -c $url -O $out/$name"
done < url.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment