0

I have a script that gets a list of files from google drive

from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LoadCredentialsFile("mycreds.txt")

gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
    gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
    gauth.Refresh()
else:
    gauth.Authorize()
gauth.SaveCredentialsFile("mycreds.txt")

gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)

folder = "1CNtWRS005fkX6vlZowZiXYITNGifXPKS"

file_list = drive.ListFile({'q': f"'{folder}' in parents"}).GetList()

for file in file_list:
    print(file['title'])

-> 1.txt

It receives data only from its disk, but I need the script to receive a list of files from a folder to which it has access - "available to me". I have a folder ID, but if I substitute it in the folder field, nothing happens

auem
  • 45
  • 7
  • Does this answer your question? [Python: download files from google drive using url](https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url) – Shridhar Patil Jul 26 '22 at 07:33

1 Answers1

0

I think gdown could help you.

pip install gdown

Then could try something like this:

import gdown

id = "folderId..."
gdown.download_folder(id=id, quiet=True, use_cookies=False)
user1
  • 19
  • 4
  • But I have to get not the whole folder, but only a specific file from it. The file is searched by name – auem Jul 28 '22 at 12:56