76 lines
1.8 KiB
Batchfile
76 lines
1.8 KiB
Batchfile
@echo off
|
|
setlocal ENABLEDELAYEDEXPANSION
|
|
|
|
cd /d "%~dp0"
|
|
|
|
echo --- Mise en prod Ratio_Restauration ---
|
|
|
|
set "ROOT=%~dp0.."
|
|
|
|
set "VERSION_FILE=%ROOT%\Excel\dev\Ratio_Restauration_VERSION.txt"
|
|
set "SRC=%ROOT%\Excel\dev\Ratio_Restauration_dev.xlsm"
|
|
set "DST_DIR=%ROOT%\Excel\prod"
|
|
set "DST=%DST_DIR%\Ratio_Restauration.xlsm"
|
|
set "BACKUP_DIR=%ROOT%\Excel\backup"
|
|
set KEEP_BACKUPS=10
|
|
|
|
set "OLD_VERSION="
|
|
if exist "%VERSION_FILE%" (
|
|
set /p OLD_VERSION=<"%VERSION_FILE%"
|
|
)
|
|
|
|
if not exist "%SRC%" (
|
|
echo ERREUR : fichier source introuvable :
|
|
echo %SRC%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%DST_DIR%" (
|
|
echo ERREUR : dossier de destination introuvable :
|
|
echo %DST_DIR%
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist "%BACKUP_DIR%" (
|
|
mkdir "%BACKUP_DIR%"
|
|
)
|
|
|
|
if exist "%DST%" (
|
|
if "%OLD_VERSION%"=="" (
|
|
set "BACKUP=%BACKUP_DIR%\Ratio_Restauration_sansVersion.xlsm"
|
|
) else (
|
|
set "BACKUP=%BACKUP_DIR%\Ratio_Restauration_Vers%OLD_VERSION%.xlsm"
|
|
)
|
|
|
|
echo Sauvegarde de l'ancienne production...
|
|
if exist "%DST_DIR%\~$Ratio_Restauration.xlsm" (
|
|
echo ERREUR : Ratio_Restauration.xlsm est ouvert dans Excel.
|
|
exit /b 1
|
|
)
|
|
copy /Y "%DST%" "%BACKUP%"
|
|
)
|
|
|
|
echo Copie vers la version de production...
|
|
copy /Y "%SRC%" "%DST%"
|
|
|
|
if errorlevel 1 (
|
|
echo ERREUR lors de la copie vers production.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Mise à jour de version...
|
|
python "%~dp0maj_version.py" "%VERSION_FILE%" "%DST%"
|
|
|
|
if errorlevel 1 (
|
|
echo ERREUR lors de la mise à jour de version.
|
|
exit /b 1
|
|
)
|
|
|
|
echo Nettoyage des anciennes sauvegardes Restauration...
|
|
for /f "skip=%KEEP_BACKUPS% delims=" %%F in ('dir /b /a-d /o-d "%BACKUP_DIR%\Ratio_Restauration_Vers*.xlsm" 2^>nul') do (
|
|
echo Suppression ancienne sauvegarde : %%F
|
|
del /q "%BACKUP_DIR%\%%F"
|
|
)
|
|
|
|
echo --- Mise en prod terminee ---
|
|
exit /b 0 |