Salut jam92400 voilà la modif :
Code Batch : Sélectionner tout - Visualiser dans une fenêtre à part
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 @echo off chcp 1252 >nul powershell -Command "get-childItem D:\CFT\Tempus\Upload\BPM_UAT\SCAN_FRA\*.eml | rename-item -newname { $_.name -replace '!','' }" Setlocal EnableExtensions EnableDelayedExpansion cd /d %~dp0 || exit /b 1 set files=*.eml *.msg :: ------------------------------------------------------- :: Définition des variables :: ------------------------------------------------------- set today=%date:~6,4%%date:~3,2%%date:~0,2% set racine=D:\CFT\Tempus\Upload\BPM_UAT set /p LotNum=<%racine%\conf\lot.conf set LotNum=!LotNum: =! set logfile=%racine%\log\ScanFra_%today%_LOT_!LotNum!.log set horodatage=%today%T%time:~0,2%%time:~3,2% set horodatage=!horodatage: =! set ARCHIVE=%racine%\ARCHIVE set REJET=%racine%\REJET set SCAN_FRA=%racine%\SCAN_FRA set WORK_FRA=%racine%\WORK_FRA set TMP=%ARCHIVE%\TMP :: ------------------------------------------------------- :: Création de l'arborescence :: ------------------------------------------------------- if not exist "%ARCHIVE%" (mkdir "%ARCHIVE%") if not exist "%TMP%" (mkdir "%TMP%") if not exist "%racine%\conf\lot.conf" (exit /b 1) if not exist "%racine%\log" (mkdir "%racine%\log") if not exist "%REJET%" (mkdir "%REJET%") if not exist "%SCAN_FRA%\*.*" (exit /b 1) if not exist "%WORK_FRA%" (mkdir "%WORK_FRA%") :: ------------------------------------------------------- :: Tri des fichiers selon l'extension à cibler :: ------------------------------------------------------- cd /d %SCAN_FRA% set vide=0 for %%A in (%files%) do (set /a vide+=1) if !vide! EQU 0 (exit /b 1) (echo. & echo ########## Fichiers déplacés vers WORK_FRA echo. for %%A in (%files%) do (move "%%~A" "%WORK_FRA%" >nul && echo %%~A) echo. & echo. & echo. & echo ########## Fichiers déplacés vers REJET echo. move /y "*.*" "%REJET%" | find /v "fichier" echo. & echo.) >> !logfile! :: ------------------------------------------------------- :: Création des lots (30 fichiers maxi par lot) :: ------------------------------------------------------- cd %WORK_FRA% set count=0 set num=0 if not exist "###" (mkdir "###") (echo. & echo. & echo ########## Fichiers déplacés vers ARCHIVE) >> !logfile! FOR %%I IN (%files%) DO ( set /a count+=1 set /a num+=1 set index=00000!num! set index=!index:~-5! set FinalLotNum=00000000!LotNum! set FinalLotNum=!FinalLotNum:~-8! move "%%~I" "###\BNPPLS_FRA_3_!horodatage!_!FinalLotNum!_!index!%%~xI" >nul if !count! EQU 30 (call:archive) ) if exist "###\*.*" (call:archive) rmdir /s /q "###" :: ------------------------------------------------------- :: Envoi CFT :: ------------------------------------------------------- for %%G in (%TMP%\*.7z) do ( echo %%G echo start /B /wait D:\APPS\CFTG\scripts\cftxsend.bat -D AUTOMATU -I WWDDIDEM -F "%%~G" -P "U_%%~nxG" start /B /wait D:\APPS\CFTG\scripts\cftxsend.bat -D AUTOMATU -I WWDDIDEM -F "%%~G" -P "U_%%~nxG" ) rmdir /s /q %TMP% :: ------------------------------------------------------- :: Fin du programme :: ------------------------------------------------------- cd /d %racine%\log set /a last=!LotNum!-1 for /f "delims=" %%A in ('dir /b "!logfile!"') do (ren "%%~A" "%%~nA-!last!%%~xA") exit /b 0 :: ------------------------------------------------------- :: Fonction de création d'archive :: ------------------------------------------------------- :archive cls & echo. & echo ############# LOT ACTUEL = !LotNum! set zipfile=BNPPLS_FRA_3_!horodatage!_!FinalLotNum! set zipfile=!zipfile: =! pushd "###" set count=0 set num=0 "C:\Program Files\7-Zip\7z.exe" a "!zipfile!.7z" "*.*" xcopy "!zipfile!.7z" "%TMP%" move "!zipfile!.7z" "%ARCHIVE%" >nul && (((echo. & echo *** !zipfile!.7z ***) >> !logfile!) & (del /f /q "*.*" >nul 2>&1)) popd set /a LotNum+=1 echo !LotNum! > %racine%\conf\lot.conf goto :eof :: ------------------------------------------------------- :: Fonction useless :: ------------------------------------------------------- :useless timeout /t 10 goto :eof rem
Je te souhaite une bonne journée.
Partager