Konrad Mazur
Konrad Mazur

Reputation: 1

How to delete a specific file, in a specific location, if the file is larger than given size, in a batch file

How to delete a specific file, in a specific location, if the file is larger than given size, in a batch file.

Basicly what I am trying to do is create a batch file that when run will always delete a specific file if its size is larger than 100mb.

Upvotes: 0

Views: 50

Answers (1)

MC ND
MC ND

Reputation: 70923

for %%a in ("c:\somewhere\theFile.txt") do if %%~za gtr 104857600 del "%%~fa"

The for command will get a reference to the indicated file in its replaceable parameter %%a. Then %%~za will return the size of the referenced file, and %%~fa is the file name with full path.

Upvotes: 1

Related Questions