中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-28 09:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 请教一个批量删除的问题 查看 780 回复 5
楼 主 请教一个批量删除的问题 发表于 2008-07-01 23:49 ·  中国 福建 三明 电信
初级用户
★★
积分 175
发帖 108
注册 2008-05-19 01:24
18年会员
UID 119060
性别 男
状态 离线
将同一目录下的所有大小为0的.TXT 文件删除,如何写? 先谢了
2 发表于 2008-07-02 00:11 ·  中国 山东 淄博 联通
银牌会员
★★★
积分 1,604
发帖 646
注册 2008-04-13 23:39
18年会员
UID 115804
性别 男
状态 离线
for %%a in (*.txt) do if %%~za equ 0 del %%~sa
心绪平和,眼藏静谧,无比安稳的火... Purification of soul...Just a false...^_^
3 发表于 2008-07-02 01:03 ·  中国 福建 三明 电信
初级用户
★★
积分 175
发帖 108
注册 2008-05-19 01:24
18年会员
UID 119060
性别 男
状态 离线
对,谢了
4 发表于 2008-07-02 14:31 ·  中国 台湾 中华电信(HiNet)数据中心
初级用户
积分 79
发帖 45
注册 2007-11-28 15:10
18年会员
UID 104056
性别 男
状态 离线
不错,
能给解释一下 %%~za是什么意思吗?
5 发表于 2008-07-02 18:34 ·  美国 惠普HP
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
for /?

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
6 发表于 2008-07-09 01:10 ·  中国 浙江 杭州 电信
初级用户
★★
积分 157
发帖 67
注册 2007-05-13 11:03
19年会员
UID 88378
性别 男
状态 离线
for /f %%i in ('dir /b *.txt') do if %%~zi==0 del %%~nxi
论坛跳转: