robocopy MOVE fichiers

//WCTSRV0016/Batch_win/robocopy_dir_MOVE.bat
test dossier vide
move des fichiers
horodatage du log
affichage du log

setlocal enabledelayedexpansion
echo === Transfert Robocopy ===

rem ------------------------------
rem Horodatage
reg add "HKCU\Control Panel\International" /v sShortDate /d "dd-MM-yyyy" /f
for /F "tokens=1-4 delims=/" %%a in ('echo %date:~0,10%') do set w_date=%%c%%b%%a
for /F "tokens=1-4 delims=-" %%a in ('echo %date:~0,10%') do set w_date=%%c%%b%%a
for /F "tokens=1-4 delims=:" %%a in ('echo %time:~0,8%') do set w_time=%%a%%b%%c
set w_horo=%w_date%_%w_time%


set w_source=%1
set w_cible=%2
rem ------ horodatage du log 
set w_log=%3\%w_horo%_%TOM_JOB%.vlog

set /a w_err=8

echo source : %w_source%
echo cible : %w_cible%
echo log : %w_log%


echo --- source -------------
rem -- recherche si fichier à traiter
set f_tmp=L:\Soft\VTOM\logs\liste_fic_%TOM_JOB%.txt
set /a cpt=0
dir /b %w_source%  > %f_tmp%
for /f "delims=" %%i in ('type %f_tmp%') do set /a cpt+=1
echo nombfre de fichier à traiter : !cpt!
IF !cpt! EQU 0 exit /B 0

dir %w_source%

echo --- cible avant -------------
dir %w_cible%

echo Move 
echo robocopy %w_source% %w_cible% /S /Move /w:10 /r:2 /LOG+:%w_log%
robocopy %w_source% %w_cible% /S /Move /w:10 /r:2 /LOG+:%w_log%
set /a w_err=%w_err%+%errorlevel%
mkdir %w_source%

echo --- cible après -------------
dir %w_cible%

rem ---- affichage du log
type %w_log%

set /a w_err=%w_err%-8
exit /B %w_err%

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *