Compare size between two files

F

Frank W.

Hi,

in my Batch File I produce a Log-File.
If the Log-File is coming up to 10MB
I want to delete it. But I dont know any routine
or syntax that compare the size of a File.
I experiment with "DIR /Os", but there is
no idea to compare with > or < like in C.
Have anybody some idea?

Greets, Frank
 
F

Frank W.

-----Original Message-----
Frank said:
Hi,

in my Batch File I produce a Log-File.
If the Log-File is coming up to 10MB
I want to delete it. But I dont know any routine
or syntax that compare the size of a File.
I experiment with "DIR /Os", but there is
no idea to compare with > or < like in C.
Have anybody some idea?

Greets, Frank

[BEGIN SCRIPT - foo.cmd]
@echo off

if not exist "%1" (
echo File not found
goto :EOF
)

for %%S in ("%1") do (
if %%~zS GTR 1024 (
echo File is larger than 1K [%%~zS]
) else (
echo File is smaller than 1K [%%~zS]
)
)
[/SCRIPT]

[EXAMPLE OUTPUT]
C:\>foo c:\windows\win.ini
File is smaller than 1K [986]

C:\>foo windows\notepad.exe
File is larger than 1K [66048]
[/EXAMPLE OUTPUT]

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
Thank you very much,

it works great!!!

Greets, Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top