Deleting files smaller than a certain size with batch
11,365
This is possible by using a for /f
statement. The below script will all delete files below 100KB
(100,000 bytes) Try this:
@echo off
setlocal
:: Size is in bytes
set "min.size=100000"
for /f "usebackq delims=;" %%A in (`dir /b /A:-D *.*`) do If %%~zA LSS %min.size% del "%%A"
Author by
Skeleton Bow
Normal person at day. Drowsy log by night. Un tiens vaut, ce dit-on, mieux que deux tu l'auras.
Updated on June 18, 2022Comments
-
Skeleton Bow almost 2 years
Is there any way to delete all files in a specific folder that are smaller than
x MB
using a batch file?
I looked at the forfiles command, but it seems like with it you can only delete files that are older thanx days
.