How to check file size?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pstein
Posts: 125
Joined: 09 Nov 2011 01:42

How to check file size?

#1 Post by pstein » 22 Jul 2015 02:41

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to check file size?

#2 Post by foxidrive » 22 Jul 2015 03:23

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

Post Reply