Home > front end >  How to recover the size of a csv file in a batch file?
How to recover the size of a csv file in a batch file?

Time:05-06

I have to recover the size of a csv file with a batch file and I tried with this code, but when I echo the size, there is nothing inside the value. Do you have any idea of the problem ? (By the way I am in the good directory, so the path is good and I tried without .\\ and nothing change)

for %%I in (.\\Tous_les_Liens.csv) do set size = %%~zI
IF (%size% LEQ 1) (goto reussite) ELSE (goto erreurs)

:reussite
echo Tout est normal

:erreurs
echo Il y a des erreurs sur le site
echo %size%
FOR /F %%i in ('type .\\Tous_les_Liens.csv') do echo %%i
exit 9

CodePudding user response:

You do not want the first :label to call through to the error label. Try this:

for %%I in ("Tous_les_Liens.csv") do set /a "size=%%~zI"
IF %size% GTR 1 goto :erreurs

:reussite
echo Tout est normal
goto :EOF

:erreurs
echo Il y a des erreurs sur le site
echo %size%
type "Tous_les_Liens.csv"
exit 9
  • Related