mirror of
https://github.com/HKUDS/AutoAgent
synced 2026-04-21 15:47:56 +00:00
53 lines
No EOL
1.6 KiB
Python
53 lines
No EOL
1.6 KiB
Python
import tkinter as tk
|
|
from tkinter import filedialog
|
|
import shutil
|
|
import os
|
|
from rich.console import Console
|
|
|
|
def select_and_copy_files(dest_dir, console: Console):
|
|
# 创建 tkinter 根窗口但隐藏它
|
|
root = tk.Tk()
|
|
root.withdraw()
|
|
|
|
# 打开文件选择对话框
|
|
files = filedialog.askopenfilenames(
|
|
title='Select files to copy',
|
|
filetypes=[
|
|
# ('Text files', '*.txt'),
|
|
('All files', '*.*'),
|
|
('PDF files', '*.pdf'),
|
|
('Docx files', '*.docx'),
|
|
('Txt files', '*.txt'),
|
|
('Zip files', '*.zip'),
|
|
('Text files', '*.txt'),
|
|
]
|
|
)
|
|
|
|
if not files:
|
|
print("No files selected")
|
|
return
|
|
|
|
# 选择目标文件夹
|
|
# dest_dir = filedialog.askdirectory(
|
|
# title='Select destination folder'
|
|
# )
|
|
|
|
if not dest_dir:
|
|
print("No destination folder selected")
|
|
return
|
|
|
|
# 复制文件
|
|
for file_path in files:
|
|
file_name = os.path.basename(file_path)
|
|
dest_path = os.path.join(dest_dir, file_name)
|
|
try:
|
|
shutil.copy2(file_path, dest_path)
|
|
console.print(f"[bold green]Uploaded: {file_name}[/bold green]")
|
|
except Exception as e:
|
|
console.print(f"[bold red]Error uploading {file_name}: {e}[/bold red]")
|
|
|
|
console.print(f"[bold green]Successfully uploaded {len(files)} files[/bold green]")
|
|
|
|
if __name__ == "__main__":
|
|
dest_dir = "/Users/tangjiabin/Documents/reasoning/metachain/workspace_meta_showcase/showcase_nl2agent_showcase/workplace"
|
|
select_and_copy_files(dest_dir) |