robocopy
This commit is contained in:
+56
-4
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
from tkinter import filedialog, messagebox
|
||||
|
||||
@@ -10,7 +11,7 @@ class DirectorySelectorApp:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
self.root.title("Selector de Directorios")
|
||||
self.root.geometry("600x550")
|
||||
self.root.geometry("600x600")
|
||||
|
||||
# Variables de rutas
|
||||
self.path_esde_src = tk.StringVar()
|
||||
@@ -42,6 +43,12 @@ class DirectorySelectorApp:
|
||||
self.create_path_selector("Destino ES-DE:", self.path_esde_dst)
|
||||
self.create_path_selector("Destino ROMs:", self.path_roms_dst)
|
||||
|
||||
# ---------------------------
|
||||
# BOTÓN ROBOCOPY
|
||||
# ---------------------------
|
||||
tk.Button(root, text="Robocopy", font=("Arial", 12, "bold"),
|
||||
command=self.run_robocopy).pack(pady=15)
|
||||
|
||||
# Evento de cierre
|
||||
self.root.protocol("WM_DELETE_WINDOW", self.on_close)
|
||||
|
||||
@@ -87,6 +94,54 @@ class DirectorySelectorApp:
|
||||
except Exception as e:
|
||||
messagebox.showerror("Error", f"No se pudo leer la ruta:\n{e}")
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# EJECUTAR ROBOCOPY
|
||||
# ---------------------------------------------------------
|
||||
def run_robocopy(self):
|
||||
selected = [self.listbox.get(i) for i in self.listbox.curselection()]
|
||||
|
||||
if not selected:
|
||||
messagebox.showwarning("Aviso", "No has seleccionado ningún sistema.")
|
||||
return
|
||||
|
||||
esde_src = self.path_esde_src.get()
|
||||
roms_src = self.path_roms_src.get()
|
||||
esde_dst = self.path_esde_dst.get()
|
||||
roms_dst = self.path_roms_dst.get()
|
||||
|
||||
if not all([esde_src, roms_src, esde_dst, roms_dst]):
|
||||
messagebox.showerror("Error", "Debes configurar todas las rutas antes de continuar.")
|
||||
return
|
||||
|
||||
for system in selected:
|
||||
# --- ROMs ---
|
||||
src = os.path.join(roms_src, system)
|
||||
dst = os.path.join(roms_dst, system)
|
||||
self.launch_robocopy(src, dst)
|
||||
|
||||
# --- ES-DE gamelists ---
|
||||
src = os.path.join(esde_src, "gamelists", system)
|
||||
dst = os.path.join(esde_dst, "gamelists", system)
|
||||
self.launch_robocopy(src, dst)
|
||||
|
||||
# --- ES-DE downloaded_media ---
|
||||
src = os.path.join(esde_src, "downloaded_media", system)
|
||||
dst = os.path.join(esde_dst, "downloaded_media", system)
|
||||
self.launch_robocopy(src, dst)
|
||||
|
||||
messagebox.showinfo("Completado", "Robocopy finalizado.")
|
||||
|
||||
def launch_robocopy(self, src, dst):
|
||||
if not os.path.isdir(src):
|
||||
return # No existe, se ignora
|
||||
|
||||
os.makedirs(dst, exist_ok=True)
|
||||
|
||||
cmd = f'robocopy "{src}" "{dst}" /MIR'
|
||||
|
||||
# Abrir en consola visible
|
||||
subprocess.Popen(["cmd", "/c", cmd])
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# PERSISTENCIA
|
||||
# ---------------------------------------------------------
|
||||
@@ -115,18 +170,15 @@ class DirectorySelectorApp:
|
||||
except Exception:
|
||||
return
|
||||
|
||||
# Restaurar rutas
|
||||
self.path_esde_src.set(data.get("esde_src", ""))
|
||||
self.path_roms_src.set(data.get("roms_src", ""))
|
||||
self.path_esde_dst.set(data.get("esde_dst", ""))
|
||||
self.path_roms_dst.set(data.get("roms_dst", ""))
|
||||
|
||||
# Actualizar lista si ROMs origen existe
|
||||
roms_path = self.path_roms_src.get()
|
||||
if os.path.isdir(roms_path):
|
||||
self.update_directory_list(roms_path)
|
||||
|
||||
# Restaurar selección
|
||||
selected = set(data.get("selected", []))
|
||||
for i in range(self.listbox.size()):
|
||||
if self.listbox.get(i) in selected:
|
||||
|
||||
Reference in New Issue
Block a user