-1

I have found this code which works on Linux:

#!/bin/bash
fileid="FILEIDENTIFIER"
filename="FILENAME"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}

Source: wget/curl large file from google drive

The problem is the awk needs to be replaced for Windows implementation.

The way I found to do it is like instead of:

command | awk '{ print $4 }'

do something like:

for /f "tokens=4" %%a in ('command') do echo %%a

My problem is I'm not familiar with awk and the NF variable. So I don't really know how to convert $NF on batch implementation to do the exact same thing.

I found the solution. FINDSTR did the trick. So now it perfectly works with:

for /f "tokens=7" %%a in ('findstr "download" cookie.txt') do echo %%a

1 Answers1

0

The code as to answer this question for a fully functional script to download large Google Drive files using curl on a batch script on Windows is:

curl -c cookie.txt -s -L "https://drive.google.com/uc?export=download&id=FILE_ID" > nul
for /f "tokens=7" %%a in ('findstr "download" cookie.txt') do curl -Lb cookie.txt "https://drive.google.com/uc?export=download&confirm=%%a&id=YOUR_FILE_ID" -o FILENAME

Just replace FILE_ID with your Google Drive file identifier and FILENAME with your desired output filename.