Problème avec assignation de variables dans boucle
Bonjour à tous,
Je tente de faire fonctionner un script BATCH depuis plusieurs jours, j'ai bien avancé mais là je bloque.
Le script ce dessous va faire deux passages dans la boucle avec les fichiers suivants :
toto@toto.fr-tigre.xml.20316552.tar.gz
titi@titi.fr-tigre.xml.20316552.tar.gz
1)
Lors du premier passage tout ce passe bien dans les assignations SAUF pour la variable !MAIL! qui est utilisée
dans la commande blat.exe , cette variable n'est pas substituée et je ne comprends pas pourquoi
2)
Lors du traitement du second fichier rien ne va plus les variables ne sont plus affectées ce qui donne à l'exécution
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| Nom du fichier zip : !FICZIP!
Nom du fichier tar : !FICTAR!
D:\graphviz\SOSctm2graphviz\scripts>SET MAIL=!FICZIP!
Le fichier spécifié est introuvable.
gzip: D:\Control-M\Migration_6.1_to_6.3\xml_migre_graphviz_prod\TEST\!FICZIP!.gz
: No such file or directory
tar: Cannot open !FICTAR!: No such file or directory
tar: Error is not recoverable: exiting now
Impossible de trouver D:\Control-M\Migration_6.1_to_6.3\xml_migre_graphviz_prod\
TEST\!FICTAR!
Le nom de fichier existe déjà, ou le fichier
est introuvable. |
Voici mon script
Code:
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
| SetLocal EnableDelayedExpansion EnableExtensions
@echo off
SET FIC_XML=D:\Control-M\Migration_6.1_to_6.3\xml_migre_graphviz_prod\TEST
SET FIC_XML_OUT=%FIC_XML%\XML
SET PDF_OUT=%FIC_XML%\PDF
for %%a in (%FIC_XML%\*.gz) do (
SET FICZIP=%%~nxa
SET FICTAR=%%~na
echo Nom du fichier zip : !FICZIP!
echo Nom du fichier tar : !FICTAR!
REM Recuperation de l'adresse mail dans le nom du fichier
for /f "tokens=1 delims=-" %%b in ("!FICZIP!") do SET MAIL=%%b
REM dezip
copy %FIC_XML%\!FICZIP! %PDF_OUT%
gzip -df %FIC_XML%\!FICZIP!
REM detar
D:
cd %FIC_XML%
tar -xvf !FICTAR!
del !FICTAR!
move *.xml %FIC_XML_OUT%
REM Creation des PDF à partir des xml , envoi par mail puis copie dans repertoire Organigrammes
for %%i in (%FIC_XML_OUT%\*.xml) do (
D:\graphviz\SOSctm2graphviz\scripts\ctm2graphviz -DefTableFileName=%%i
D:\graphviz\release\bin\dot -Tpdf D:\graphviz\SOSctm2graphviz\tmp\DOT\%%~ni.dot -o %PDF_OUT%\%%~ni.pdf
copy %PDF_OUT%\%%~ni.pdf "V:\met\Exploit\Developpement exploit\Organigrammes\MVS\_Organigrammes_ESSAI"
echo FIN DE COPY
blat.exe -serverSMTP msg-store.ccmsa.msanet -t !MAIL! -subject "Organigramme %%~ni" -body "%%~ni" -attach %PDF_OUT%\%%~ni.pdf,%FIC_XML_OUT%\%%~ni.xml >> %TMP%\ctm_to_graphviz_error.log 2>&1
echo FIN DE BLAT
del %FIC_XML_OUT%\%%~ni.xml
del %PDF_OUT%\%%~ni.pdf
pause
)
pause
)
endlocal |