# How to download google drive files using wget

[Wget](https://www.gnu.org/software/wget/manual/wget.html) is very useful for downloading files using a terminal and automating downloading tasks. Also, it is very useful for downloading datasets on Kaggle, Google Colab, Jupyter Notebooks and Data science projects.

Downloading files from google drive using [wget](https://www.gnu.org/software/wget/manual/wget.html) is simple, you just need to know one basic thing.

There are two types of files on google drive as follows:  
1\. Small files (Files smaller than 64 MB)  
2\. Large files (Files larger than 64 MB)

### Steps:

**Note**: Before you download the file, it has to be shared publicly. Simply create a shareable link to the file. (Create a link for the file, not the folder)

1.  Get the shareable link of the file. It should look something like this.  
    https://drive.google.com/file/d/**1cDyCAGmHcHrOlJn46HvyA8X0RpiOFz**/view?usp=sharing
2.  Copy the file id from the link, i.e the bold part shown in the above link. **1cDyCAGmHcHrOlJn46HvyA8X0RpiOFz**
3.  Replace **FILEID** with the file id in the shareable link and **FILENAME** with the file name of your choice to name the downloaded file, in the following command:

For small files (file size < 64 MB):

```
wget — no-check-certificate ‘https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME
```

For large files (file size > 64 MB):

```
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=FILEID' -O- | sed -rn ‘s/.confirm=(\[0–9A-Za-z\_\]+)./\\1\\n/p’)&id=FILEID” -O FILENAME && rm -rf /tmp/cookies.txt
```

(If you want to hide the output of the above command, just add -q flag for quiet mode)  
With quiet mode your command should begin as follows:

```
wget -q — ……
```
