pll / New Text Document.bat
CineMax's picture
Upload 11 files
182cdfb verified
@echo off
setlocal enabledelayedexpansion
REM Solicitar la URL del repositorio, el número de archivos de video por lote y el número de archivos de audio a enviar en cada lote
set /p REPO_URL="Introduce la URL del repositorio (por ejemplo, https://github.com/Armando287/pg.git): "
set /p videoBatchSize="Introduce el número de archivos de video .ts a enviar en cada lote (por ejemplo, 50 o 100): "
set /p audioBatchSize="Introduce el número de archivos de audio .ts a enviar en cada lote (por ejemplo, 50 o 100): "
set BRANCH=main
set WORK_DIR=%~dp0
REM Cambia al directorio del script
cd /d "%WORK_DIR%"
REM Inicializa el repositorio si no existe
if not exist .git (
echo Inicializando el repositorio Git...
git init
git remote add origin %REPO_URL%
git fetch origin %BRANCH%
git checkout -b %BRANCH%
)
REM Procesar archivos .m3u8
echo Procesando archivos .m3u8...
set /a m3u8Counter=0
REM Recolectar archivos .m3u8
for /f "delims=" %%f in ('dir /b /a-d *.m3u8') do (
set "file=%%f"
echo Archivo .m3u8 detectado: "!file!"
git add "!file!"
set /a m3u8Counter+=1
)
REM Hacer commit y push para archivos .m3u8 si se procesaron
if %m3u8Counter% gtr 0 (
echo Haciendo commit y push para archivos .m3u8...
git commit -m "Subida automática de archivos .m3u8"
if !ERRORLEVEL! neq 0 (
echo Error al hacer commit. Error nivel: !ERRORLEVEL!
exit /b 1
)
git push origin %BRANCH%
if !ERRORLEVEL! neq 0 (
echo Error al hacer push. Intentando hacer pull para resolver conflictos...
git pull origin %BRANCH%
echo Intentando hacer push nuevamente...
git push origin %BRANCH%
)
)
REM Procesar archivos .ts con "video" en el nombre en lotes
echo Procesando archivos .ts con "video" en el nombre en lotes...
set /a videoCounter=0
set /a videoBatchCount=0
REM Recolectar archivos .ts que contengan "video" en el nombre
for /f "delims=" %%f in ('dir /b /a-d *video*.ts') do (
set "file=%%f"
echo Archivo de video .ts detectado: "!file!"
git add "!file!"
set /a videoCounter+=1
REM Cada videoBatchSize archivos, hace commit y push
if !videoCounter! geq %videoBatchSize% (
echo Haciendo commit y push de %videoBatchSize% archivos de video .ts...
git commit -m "Subida automática de lote de archivos de video .ts"
if !ERRORLEVEL! neq 0 (
echo Error al hacer commit. Error nivel: !ERRORLEVEL!
exit /b 1
)
git push origin %BRANCH%
if !ERRORLEVEL! neq 0 (
echo Error al hacer push. Intentando hacer pull para resolver conflictos...
git pull origin %BRANCH%
echo Intentando hacer push nuevamente...
git push origin %BRANCH%
)
set /a videoCounter=0
set /a videoBatchCount+=1
)
)
REM Realiza commit y push para los archivos de video .ts restantes (si quedan menos de %videoBatchSize%)
if !videoCounter! gtr 0 (
echo Haciendo commit y push para los archivos de video .ts restantes...
git commit -m "Subida automática de los archivos de video .ts restantes"
if !ERRORLEVEL! neq 0 (
echo Error al hacer commit. Error nivel: !ERRORLEVEL!
exit /b 1
)
git push origin %BRANCH%
if !ERRORLEVEL! neq 0 (
echo Error al hacer push. Intentando hacer pull para resolver conflictos...
git pull origin %BRANCH%
echo Intentando hacer push nuevamente...
git push origin %BRANCH%
)
)
REM Procesar archivos .ts con "audio" en el nombre en lotes
echo Procesando archivos .ts con "audio" en el nombre en lotes...
set /a audioCounter=0
set /a audioBatchCount=0
REM Recolectar archivos .ts que contengan "audio" en el nombre
for /f "delims=" %%f in ('dir /b /a-d *audio*.ts') do (
set "file=%%f"
echo Archivo de audio .ts detectado: "!file!"
git add "!file!"
set /a audioCounter+=1
REM Cada audioBatchSize archivos, hace commit y push
if !audioCounter! geq %audioBatchSize% (
echo Haciendo commit y push de %audioBatchSize% archivos de audio .ts...
git commit -m "Subida automática de lote de archivos de audio .ts"
if !ERRORLEVEL! neq 0 (
echo Error al hacer commit. Error nivel: !ERRORLEVEL!
exit /b 1
)
git push origin %BRANCH%
if !ERRORLEVEL! neq 0 (
echo Error al hacer push. Intentando hacer pull para resolver conflictos...
git pull origin %BRANCH%
echo Intentando hacer push nuevamente...
git push origin %BRANCH%
)
set /a audioCounter=0
set /a audioBatchCount+=1
)
)
REM Realiza commit y push para los archivos de audio .ts restantes (si quedan menos de %audioBatchSize%)
if !audioCounter! gtr 0 (
echo Haciendo commit y push para los archivos de audio .ts restantes...
git commit -m "Subida automática de los archivos de audio .ts restantes"
if !ERRORLEVEL! neq 0 (
echo Error al hacer commit. Error nivel: !ERRORLEVEL!
exit /b 1
)
git push origin %BRANCH%
if !ERRORLEVEL! neq 0 (
echo Error al hacer push. Intentando hacer pull para resolver conflictos...
git pull origin %BRANCH%
echo Intentando hacer push nuevamente...
git push origin %BRANCH%
)
)
echo Subida completada.
pause