How to download files or folders in google drive in python

less than 1 minute read

Hello, today we are going to download files and folders with Python from Google Drive.

a. open Google Drive

b. Right-click on your file

c. Click on Get Link

d. Make sure your file is available for “Anyone with the link

get shareable link

e. Click on Copy Link

2. Install gdown

!pip install gdown

3. Download the file in google drive using Python

import gdown

url = 'https://drive.google.com/file/d/1uFTzwFc3tmS-D7azjMiJcxSfn71BPqKt/view?usp=sharing'
output_path = 'myfile.txt'
gdown.download(url, output_path, quiet=False,fuzzy=True)

4. Download a folder in google drive using Python

import gdown
url = "https://drive.google.com/drive/folders/1HWFHKCprFzR7H7TYhrE-W7v4bz2Vc7Ia"
gdown.download_folder(url, quiet=True, use_cookies=False)

Congratulations!, We have learned how to download files in python from google drive.

Posted:

Leave a comment