gpt4 book ai didi

windows - 删除小于特定大小的文件

转载 作者:可可西里 更新时间:2023-11-01 09:46:31 30 4
gpt4 key购买 nike

我想删除目录中所有小于特定大小的文件。有谁知道是否有 Windows 命令可以执行此操作?类似 del *.* where size<3kb 的东西

我目前正在这样做:

for /F %%A in ("*.pdf") do If %%~zA LSS 20103409 del %%~fA

我得到的输出是:

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 文件小到可以删除。

我做错了什么?

这确实有效:

FOR %%F IN (*.pdf) DO (
IF %%~zF LSS 20103409 DEL %%F
)

但是它无法识别文件名,因为它们有空格!如何在该脚本中将 Windows 名称转换为“DOS”名称?例如,Windows 名称是 file name.pdf我可能需要转换为“DOS”,它看起来像这样 file_name.pdf或类似的东西。

最佳答案

在批处理脚本中试试这个:

@echo off
setlocal
for /f "usebackq delims=;" %%A in (`dir /b *.pdf`) do If %%~zA LSS 3145728 del "%%A"

关于windows - 删除小于特定大小的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6764621/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com