1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| @echo off
chcp 1252 >nul
set files=eml
powershell -Command "get-childItem D:\CFT\Tempus\Upload\BPM_UAT\SCAN_FRA\*.%files% | rename-item -newname { $_.name -replace '!','' }"
Setlocal EnableExtensions EnableDelayedExpansion
cd /d %~dp0 || exit /b 1
Rem ---- définition des variables---
set currentpath=%~dp0
set today=%date:~6,4%%date:~3,2%%date:~0,2%
set logdir=%currentpath%log
REM set logfile=%logdir%\scan_fra_%today%_%time:~0,2%h%time:~3,2%%time:~6,2%.log
set /p LotNum=<%currentpath%conf\lot.conf
set LotNum=!LotNum: =!
set logfile=%logdir%\ScanFra_%today%_LOT_!LotNum!.log
set /a LotNumNext=!LotNum!+1
echo lot actuel = !LotNum!
echo lot suivant = !LotNumNext!
set hour=%time:~0,2%
set min=%time:~3,2%
set horodatage=%today%T%hour%%min%
set horodatage=!horodatage: =!
set repWork=%~dp0WORK_FRA
set repScan=%~dp0SCAN_FRA
set repArch=%~dp0ARCHIVE
set repRejet=%~dp0REJET
Rem ------------------------
REM ---- Fonction pour compléter le numéro de lot avec des 0 devant pour respecter la taille de String 8 ----
set FinalLotNum=00000000!LotNum!
set FinalLotNum=!FinalLotNum:~-8!
REM -----------fin bloc de fonction -------
REM ---- Définiton du nom du zip en sortie -----------
set zipfile=BNPPLS_FRA_2_!horodatage!_!FinalLotNum!
set zipfile=!zipfile: =!
REM ------- fin définition du nom de zip -----
Rem ----Debut programme -------
if not exist "%logdir%" (mkdir "%logdir%")
(echo. & echo ########## Fichiers déplacés vers WORK_FRA
echo.) >> !logfile!
move "%repScan%\*.%files%" "%repWork%" >> !logfile!
(echo. & echo. & echo ########## Fichiers déplacés vers REJET
echo.) >> !logfile!
2>nul move /y "%repScan%\*.*" "%repRejet%" >> !logfile!
(echo. & echo.) >> !logfile!
cd %repWork%
REM ---
set count=0
set num=0
set var=0
if not exist "###" (mkdir "###")
FOR %%I IN (*.%files%) DO (
set /a count+=1
set /a num+=1
set index=0000!num!
set index=!index:~-5!
move "%%~I" "###\!zipfile!_!index!.%files%" >nul && echo [!index!] %%~I >> !logfile!
if !count! EQU 30 (call:archive)
)
if exist "###\*.%files%" (call:archive)
rmdir /s /q "###"
Rem "C:\Program Files\WinZip\Winzip8.1_FR\WINZIP32.exe" -a "!zipfile!.zip" "*.%files%" >> !logfile!
Rem "C:\Program Files\7-Zip\7z.exe" a "!zipfile!.7z" "*.%files%" >> !logfile!
Rem --- incrémentation du numéro de lot -----
echo !LotNumNext! > %currentpath%conf\lot.conf
Rem ----- Envoi CFT -----------
set part=AUTOMATU
set idf=WWDDIDEM
set env=U
REM D:\APPS\CFTG\scripts\cftxsend.bat -D "%part%" -I "%idf%" -F "%chemin%+%fichier%" -P "%env%_%fichier%" –O “RUSER=CANON01M,SUSER=10000000,SAPPL=0x515E7A98”
REM D:\APPS\CFTG\scripts\cftxsend.bat -D "%part%" -I "%idf%" -F "!zipfile!.7z" -P "%env%_%zipfile%"
REM D:\APPS\CFTG\scripts\cftxsend.bat -D "AUTOMATQ" -I "WWDDIDEM" -F "!zipfile!.7z" -P "Q_%zipfile%"
REM D:\APPS\CFTG\scripts\cftxsend.bat -D "AUTOMATU" -I "WWDDIDEM" -F "!zipfile!.7z" -P "U_%zipfile%"
Rem ----- fin envoi CFT -------
notepad !logfile!
exit /b 0
:archive
pushd "###"
set count=0
set /a var+=1
set compteur=0000!var!
set compteur=!compteur:~-5!
7za.exe a "!zipfile!_!compteur!.7z" "*.%files%"
(echo. & echo. & echo ########## Fichier déplacé vers ARCHIVE
echo.) >> !logfile!
move "!zipfile!_!compteur!.7z" "%repArch%" >nul && echo *** !zipfile!_!compteur!.7z *** >> !logfile!
del /f /q "*.*"
(echo. & echo.) >> !logfile!
popd
goto :eof |
Partager