Can't found the variable with number

2019-09-09 03:47发布

问题:

echo off
SETLOCAL EnableDelayedExpansion
set caminho="C:\Users\%username%\AppData\Local\Microsoft\Outlook"

set maxbytesize=10



for /F %%i in ('dir /b "C:\Users\%username%\AppData\Local\Microsoft\Outlook\*.ost"') do (


   set directoria=%caminho%\%%i

%1 %0 :: %directoria%
set len=%~z2

if %len% LSS %maxbytesize% (
msg * algo
PAUSE

) ELSE (
msg * O ficheiro exedeu 29Gb, diriga-se a Informatica

)

)

Im not so good in this so i need some help. I have a similar code that works, but when i "transform" into this it starts to say that 10 is not expected being 10 the %maxbytesize%. There some way to make this work or i need to start all over again??

回答1:

None of those variables need setting because they are not used outside of the code or manipulated within the code:

@Echo Off
Rem If "%~1"=="" Exit/B

Set "MaxByteSize=31138512896"

For %%A In ("%LocalAppData%\Microsoft\Outlook\*.ost") Do (
    Rem "%~1" "%~f0" :: "%%~fA"
    If %%~zA Lss %MaxByteSize% (msg * algo) Else (
        msg * O ficheiro exedeu 29Gb, diriga-se a Informatica))

If you really are running the script with a single argument then remove both instances of Rem.