forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanaging_local_files.py
More file actions
42 lines (31 loc) · 1.14 KB
/
Copy pathmanaging_local_files.py
File metadata and controls
42 lines (31 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
from copilot import CopilotClient
import os
# Create and start client
client = CopilotClient()
client.start()
# Create session
session = client.create_session(model="gpt-5")
# Event handler
def handle_event(event):
if event["type"] == "assistant.message":
print(f"\nCopilot: {event['data']['content']}")
elif event["type"] == "tool.execution_start":
print(f" → Running: {event['data']['toolName']}")
elif event["type"] == "tool.execution_complete":
print(f" ✓ Completed: {event['data']['toolCallId']}")
session.on(handle_event)
# Ask Copilot to organize files
# Change this to your target folder
target_folder = os.path.expanduser("~/Downloads")
session.send(prompt=f"""
Analyze the files in "{target_folder}" and organize them into subfolders.
1. First, list all files and their metadata
2. Preview grouping by file extension
3. Create appropriate subfolders (e.g., "images", "documents", "videos")
4. Move each file to its appropriate subfolder
Please confirm before moving any files.
""")
session.wait_for_idle()
session.destroy()
client.stop()