Skip to content

Instantly share code, notes, and snippets.

@mayflower12
Created July 12, 2018 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayflower12/02c8f1cbeadc074bc52e480815b042ff to your computer and use it in GitHub Desktop.
Save mayflower12/02c8f1cbeadc074bc52e480815b042ff to your computer and use it in GitHub Desktop.
Bulk download and rename file
#!/bin/sh
mkdir RGD_PDF
counter=0
for id in `cut -d "=" -f 2 google_file_links`;
do
echo $((counter++));
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=${id}' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${id}" -O RGD_PDF/RGD_$counter.pdf && rm -rf /tmp/cookies.txt
done;
@mayflower12
Copy link
Author

create a file 'google_file_links' with all the links to download the file.

@mayflower12
Copy link
Author

bash dl.sh

@mayflower12
Copy link
Author

To generate pdf files with file name 1.pdf 2.pdf..., simply change the 'RGD_$counter.pdf' to '$counter.pdf'.
Then use pdftk to combine all the files in order with the following command:
pdftk *.pdf cat output newfile.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment