I would like to delete all files that are less than a specific size in a directory. Does anyone know if there is a Windows command that will do this? something like del *.* where size<3kb
I am currently doing this:
for /F %%A in ("*.pdf") do If %%~zA LSS 20103409 del %%~fA
and the ouput I get is:
C:\Documents and Settings\agordon\Desktop\test>If 6440450 LSS 20103409 del C:\Do
cuments and Settings\agordon\Desktop\test\US Tox 01-06-11.pdf
The system cannot find the path specified.
...even though that PDF file is small enough to be deleted.
What am I doing wrong?
This is actually working:
FOR %%F IN (*.pdf) DO (
IF %%~zF LSS 20103409 DEL %%F
)
However it is not recognizing the file names because they have spaces! How do I convert the Windows name to a "DOS" name in that script? For example, the Windows name is file name.pdf
I would probably need to convert to "DOS" and it would look like this file_name.pdf
or something like that.
Try this from a batch script:
@echo off
setlocal
for /f "usebackq delims=;" %%A in (`dir /b *.pdf`) do If %%~zA LSS 3145728 del "%%A"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With