import tkinter
from aligo import Aligo
from tkinter import filedialog
if __name__ == '__main__':
ali = Aligo()
user = ali.get_user()
tk = tkinter.Tk()
tk.title('选择需要同步的文件夹')
tk.withdraw()
directory = filedialog.askdirectory(initialdir='C:\\Users\\Administrator\\Documents\\云盘同步')
if len(directory) == 0:
exit(1)
folder_path = input('请输入云盘文件夹:')
folder = ali.get_folder_by_path(folder_path)
if folder is None:
create_folder = input('云盘文件夹[%s]不存在,是否创建?(yes):' % folder_path)
if create_folder.lower() == 'yes':
folder = ali.create_folder(folder_path)
print('云盘文件夹[%s]创建完成' % folder_path)
else:
print('云盘文件夹[%s]不存在,同步已取消' % folder_path)
exit(1)
print('准备同步文件 [%s] <--> [%s]', directory, folder.file_name)
ali.sync_folder(directory, folder.file_id)
print('文件同步完成')
标签:文件夹,同步,ali,云盘,阿里,本地,path,folder
From: https://www.cnblogs.com/huanruke/p/16982395.html