-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (26 loc) · 1.03 KB
/
main.py
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
import os
import tkinter as tk
from tkinter import filedialog
def select_files():
files = filedialog.askopenfilenames(title="Select Files", filetypes=[("All Files", "*.*")])
if files:
output_directory = filedialog.askdirectory(title="Select Output Directory")
create_symlinks(files, output_directory)
def create_symlinks(files, output_directory):
for file_path in files:
file_name = os.path.basename(file_path)
symlink_path = os.path.join(output_directory, file_name) # uses the same name as OG file
# creates the link
try:
os.symlink(file_path, symlink_path)
print(f"Created symlink: {symlink_path}")
except OSError as e:
print(f"Error creating symlink: {e}")
# main window
root = tk.Tk()
root.title("Symbolic Link Creator")
# button to trigger file selection
select_button = tk.Button(root, text="Select Files", command=select_files)
select_button.pack(pady=20)
# run the tkinter event loop
root.mainloop()