Upload 15 files
Browse files
scripts/Filtro_Borrado_Waifus/filtro_borrando_waifus.bat
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
:: Configurar UTF-8 para nombres con caracteres extraños
|
| 3 |
+
chcp 65001 >nul
|
| 4 |
+
|
| 5 |
+
:: NO USAR DelayedExpansion porque rompe rutas con signos de exclamación (!)
|
| 6 |
+
:: como la carpeta "Poringa!" donde se encuentra este script.
|
| 7 |
+
|
| 8 |
+
cd /d "%~dp0"
|
| 9 |
+
|
| 10 |
+
echo ========================================================
|
| 11 |
+
echo LIMPIEZA SEGURA INVERSA (Compatible con rutas especiales)
|
| 12 |
+
echo Eliminando archivos que SI contengan "waifu"...
|
| 13 |
+
echo ========================================================
|
| 14 |
+
echo.
|
| 15 |
+
|
| 16 |
+
:: Recorrer archivos y procesar uno a uno en una subrutina
|
| 17 |
+
for /r %%F in (*) do call :ProcesarArchivo "%%F"
|
| 18 |
+
|
| 19 |
+
echo.
|
| 20 |
+
echo ========================================================
|
| 21 |
+
echo Limpieza finalizada.
|
| 22 |
+
echo ========================================================
|
| 23 |
+
pause
|
| 24 |
+
goto :eof
|
| 25 |
+
|
| 26 |
+
:: ---------------------------------------------------------
|
| 27 |
+
:: Subrutina para verificar y borrar cada archivo
|
| 28 |
+
:: ---------------------------------------------------------
|
| 29 |
+
:ProcesarArchivo
|
| 30 |
+
set "archivo=%~nx1"
|
| 31 |
+
set "rutacompleta=%~1"
|
| 32 |
+
set "propio_script=%~nx0"
|
| 33 |
+
|
| 34 |
+
:: 1. No borrar el script mismo
|
| 35 |
+
if /i "%archivo%"=="%propio_script%" goto :eof
|
| 36 |
+
|
| 37 |
+
:: 2. Buscar "waifu" en el nombre (ignorar mayusculas/minusculas)
|
| 38 |
+
echo "%archivo%" | find /i "waifu" >nul
|
| 39 |
+
|
| 40 |
+
:: 3. Si errorlevel es 0 o no es 1, SI se encontro el texto -> Borrar
|
| 41 |
+
if not errorlevel 1 (
|
| 42 |
+
echo [ELIMINANDO] "%archivo%"
|
| 43 |
+
del /f /q "%rutacompleta%"
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
goto :eof
|
scripts/creador de zip/crear_zips.bat
CHANGED
|
@@ -1,20 +1,6 @@
|
|
| 1 |
@echo off
|
| 2 |
chcp 65001 >nul
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
echo CREADOR DE ZIPS POR SUBCARPETA
|
| 7 |
-
echo ========================================================
|
| 8 |
-
echo.
|
| 9 |
-
echo Comprimiendo cada subcarpeta en un archivo .zip...
|
| 10 |
-
echo.
|
| 11 |
-
|
| 12 |
-
for /d %%I in (*) do (
|
| 13 |
-
echo Comprimiendo: "%%~I"
|
| 14 |
-
powershell -NoProfile -Command "Compress-Archive -Path '.\%%~I\*' -DestinationPath '.\%%~I.zip' -Force"
|
| 15 |
-
echo Listo: "%%~I.zip"
|
| 16 |
-
echo --------------------------------------------------------
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
echo Todos los procesos han terminado.
|
| 20 |
pause
|
|
|
|
| 1 |
@echo off
|
| 2 |
chcp 65001 >nul
|
| 3 |
+
title Creador de Zips Optimizado
|
| 4 |
+
:: Ejecutar el script original de Python dedicado
|
| 5 |
+
python "%~dp0crear_zips.py"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
pause
|
scripts/creador de zip/crear_zips.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import zipfile
|
| 3 |
+
import time
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 6 |
+
|
| 7 |
+
def zip_folder(folder_path: Path, output_zip: Path) -> tuple[str, str, str]:
|
| 8 |
+
"""
|
| 9 |
+
Comprime una carpeta entera en un archivo .zip de manera segura.
|
| 10 |
+
Maneja excepciones y evita incluir la carpeta raíz dentro del zip,
|
| 11 |
+
soltando todos los archivos directamente.
|
| 12 |
+
"""
|
| 13 |
+
try:
|
| 14 |
+
# Verificar si la carpeta está vacía
|
| 15 |
+
if not any(folder_path.iterdir()):
|
| 16 |
+
return str(folder_path.name), "SALTADO: Carpeta vacía", "⏳"
|
| 17 |
+
|
| 18 |
+
# Comprimir usando Deflate con un balance excelente de velocidad y compresión
|
| 19 |
+
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED, compresslevel=6) as zipf:
|
| 20 |
+
for root, dirs, files in os.walk(folder_path):
|
| 21 |
+
for file in files:
|
| 22 |
+
file_path = Path(root) / file
|
| 23 |
+
try:
|
| 24 |
+
arcname = file_path.relative_to(folder_path)
|
| 25 |
+
zipf.write(file_path, arcname)
|
| 26 |
+
except Exception as e_file:
|
| 27 |
+
print(f"⚠️ Error al leer el archivo {file_path}: {e_file}")
|
| 28 |
+
|
| 29 |
+
return str(folder_path.name), "OK", "✅"
|
| 30 |
+
|
| 31 |
+
except Exception as e:
|
| 32 |
+
# Si hubo un error catastrófico, eliminamos el .zip a medio crear
|
| 33 |
+
if output_zip.exists():
|
| 34 |
+
try:
|
| 35 |
+
output_zip.unlink()
|
| 36 |
+
except:
|
| 37 |
+
pass
|
| 38 |
+
return str(folder_path.name), f"ERROR: {str(e)}", "❌"
|
| 39 |
+
|
| 40 |
+
def main():
|
| 41 |
+
print("="*65)
|
| 42 |
+
print(" 🚀 CREADOR DE ZIPS POR SUBCARPETA PARALELO 🚀")
|
| 43 |
+
print("="*65)
|
| 44 |
+
print("")
|
| 45 |
+
|
| 46 |
+
current_dir = Path(__file__).parent.resolve()
|
| 47 |
+
|
| 48 |
+
subdirs = [d for d in current_dir.iterdir() if d.is_dir()]
|
| 49 |
+
|
| 50 |
+
if not subdirs:
|
| 51 |
+
print("⚠️ No se encontraron carpetas para comprimir en este directorio.")
|
| 52 |
+
return
|
| 53 |
+
|
| 54 |
+
print(f"📦 Encontradas {len(subdirs)} carpetas listas para comprimir.\n")
|
| 55 |
+
|
| 56 |
+
start_time = time.time()
|
| 57 |
+
|
| 58 |
+
success_count: int = 0
|
| 59 |
+
skip_count: int = 0
|
| 60 |
+
error_count: int = 0
|
| 61 |
+
|
| 62 |
+
max_workers = min(32, (os.cpu_count() or 1) + 4)
|
| 63 |
+
|
| 64 |
+
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
| 65 |
+
futures = {}
|
| 66 |
+
for folder in subdirs:
|
| 67 |
+
zip_path = current_dir / f"{folder.name}.zip"
|
| 68 |
+
futures[executor.submit(zip_folder, folder, zip_path)] = folder.name
|
| 69 |
+
|
| 70 |
+
for future in as_completed(futures):
|
| 71 |
+
folder_name = futures[future]
|
| 72 |
+
try:
|
| 73 |
+
name, status, icon = future.result()
|
| 74 |
+
|
| 75 |
+
print(f"{icon} Comprimiendo: '{name}' -> [{status}]")
|
| 76 |
+
|
| 77 |
+
if "OK" in status:
|
| 78 |
+
success_count += 1
|
| 79 |
+
elif "SALTADO" in status:
|
| 80 |
+
skip_count += 1
|
| 81 |
+
else:
|
| 82 |
+
error_count += 1
|
| 83 |
+
|
| 84 |
+
except Exception as exc:
|
| 85 |
+
print(f"❌ Comprimiendo: '{folder_name}' -> [ERROR CRÍTICO: {exc}]")
|
| 86 |
+
error_count += 1
|
| 87 |
+
|
| 88 |
+
end_time = time.time()
|
| 89 |
+
elapsed = end_time - start_time
|
| 90 |
+
|
| 91 |
+
print("\n" + "="*65)
|
| 92 |
+
print(f"🏁 Proceso completado exitosamente en {elapsed:.2f} segundos.")
|
| 93 |
+
print(f"📊 Resumen general: {success_count} procesados | {skip_count} saltados | {error_count} errores")
|
| 94 |
+
print("="*65)
|
| 95 |
+
|
| 96 |
+
if __name__ == '__main__':
|
| 97 |
+
main()
|