Page 1 of 1

How to check file size?

Posted: 22 Jul 2015 02:41
by pstein
I want to check if a file size is greater than a certain size (and perform some commands if yes).
So I need a code similar to

if filesize("myfile.txt") > 300 (
....)

How can I do this in a DOS batch script?

Thank you
Peter

Re: How to check file size?

Posted: 22 Jul 2015 03:23
by foxidrive
This is untested - works up to filesizes of 2 GB

Code: Select all

for %%a in ("file.txt") do if %%~za GTR 3000 echo larger than 3000 bytes