删除文件小于特定大小 [英] Delete files less than a specific size
问题描述
我想删除小于目录中的特定大小的所有文件。有谁知道是否有一个Windows命令,将做到这一点?像德尔* *其中大小和LT; 3KB
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
我目前这样做:
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.
...即使该PDF文件是小到足以被删除。
...even though that PDF file is small enough to be deleted.
我在做什么错了?
这是实际工作:
FOR %%F IN (*.pdf) DO (
IF %%~zF LSS 20103409 DEL %%F
)
然而,它不能识别的文件名,因为他们有空间!如何转换的Windows名称在脚本中的DOS叫什么名字?例如,Windows的名称为文件name.pdf
我可能会需要转换为DOS,它看起来像这样 file_name.pdf
或类似的东西。
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"
这篇关于删除文件小于特定大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!