Есть гораздо более простой способ, который имеет больше смысла. после установки Python и Gam вы можете запустить скрипт, который использует идентификатор файла с google drive в файле csv для экспорта всех документов из списка. После установки python и gam вам потребуется установить некоторые модули, чтобы скрипт работал. Когда вы запускаете скрипт, коды ошибок можно погуглить, чтобы увидеть, что нужно установить в Python. Также вам нужно будет создать учетную запись службы учетных данных API и заменить имя этой учетной записи на в сценарии в обоих местах. Запустите cmd от имени администратора с помощью следующей команды с именем сценария script.py. "C: \ Users \ dcahoon \ AppData \ Local \ Programs \ Python \ Python38 \ python .exe C: \ GAM \ SCRIPT.PY ** запуск сценария
import os
import subprocess
from csv import writer
from csv import reader
# path to googleidlist.csv
csvfile = 'c:\\GAM\\googleidlist.csv'
destination = 'c:\\GAM\\OUTPUT\\' #Destination for downloaded documents
# Open the input_file in read mode and output_file in write mode
with open(csvfile, 'r') as read_obj, \
open('output_1.txt', 'w', newline='') as write_obj:
# Create a csv.reader object from the input file object
csv_reader = reader(read_obj)
# Create a csv.writer object from the output file object
csv_writer = writer(write_obj)
# Read each row of the input csv file as list
for row in csv_reader:
file_id = row[0]
outcome = subprocess.Popen(['gam', 'user', 'googleserviceaccountname', 'get', 'drivefile', 'id', file_id, 'targetfolder',destination], stdout=subprocess.PIPE)
# os.system("gam user david.bruinsma@colonialmed.com show fileinfo "+ file_id + "name")
filename = subprocess.Popen(['gam', 'user', 'googleserviceaccountname', 'show', 'fileinfo', file_id, 'name' ], stdout=subprocess.PIPE)
output = outcome.stdout.readline()
file_name = filename.stdout.readline()
print(output)
# Append the default text in the row / list
# row.append(filename)
row.append(output)
row.append(file_name)
row.append(file_id)
# Add the updated row / list to the output file
csv_writer.writerow(row)