-1

I'm using this solution which Compo gave.

But when I run the bat and get two else in…

If %%~zA Lss %MaxByteSize% (msg * algo) Else (
msg * O ficheiro exedeu 29Gb, diriga-se a Informatica))

…and have, for example another batch or a vb program, it will open it more than once, which is annoying.

Is there a way to make it possible not to open several times with something like:

If %%~zA Lss %MaxByteSize% (msg * algo) 
Else (
 If %something% lss 1 (msg * O ficheiro exedeu 29Gb, diriga-se a Informatica)
 Else ( )
%something%=%something%+1
)

I'm not so good with code so that's why I'm "grabbing" code here and there.

Community
  • 1
  • 1
  • 4
    Run in a command prompt window `if /?` and read output help and see for example answers on [batch scripting - if exist ./sdcard/file.any using adb](http://stackoverflow.com/a/34118487/3074564) and on [IF ELSE syntax error within batch file?](http://stackoverflow.com/a/25471786/3074564) – Mofi Mar 02 '17 at 10:22

1 Answers1

0

Perhaps you're looking for something like this:

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

Set "MaxByteSize=31138512896"

Set "i=0"
For %%A In ("%LocalAppData%\Microsoft\Outlook\*.ost") Do (
    Rem "%~1" "%~f0" :: "%%~fA"
    If %%~zA Gtr %MaxByteSize% Set/A "i+=1")
msg * %i% ficheiro exedeu 29Gb, diriga-se a Informatica

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

Compo
  • 36,585
  • 5
  • 27
  • 39