|
eckert
初级用户
 
积分 41
发帖 14
注册 2006-9-30
状态 离线
|
『楼 主』:
自动判断文件夹是否为空。是空文件夹则删除!
使用 LLM 解释/回答一下
自动判断文件夹是否为空。是空文件夹则删除!
for /l %%a in (1,1,3) do for/r %%i in (.) do rd %%~si
帮我看看这个有没有什么错误。。
可以用在LJ 文件清理里面么?
Automatically determine whether a folder is empty. If it is an empty folder, delete it!
for /l %%a in (1,1,3) do for/r %%i in (.) do rd %%~si
Let me see if there are any errors.
Can it be used in LJ file cleaning?
|
|
2008-2-22 00:47 |
|
|
lotus516
高级用户
    论坛上抢劫的
积分 551
发帖 246
注册 2006-9-21
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r" do rd "%%a" 2>nul
|
|
2008-2-23 00:53 |
|
|
cad55
高级用户
   
积分 620
发帖 329
注册 2007-12-5
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
Originally posted by lotus516 at 2008-2-23 12:53 AM:
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul
高手呀....
再请问一下..
怎样搜索删除.0字节的所有类型的文件.
Originally posted by lotus516 at 2008-2-23 12:53 AM:
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul
Expert...
Also, may I ask...
How to search and delete all types of files with 0 bytes.
|
|
2008-2-23 09:26 |
|
|
zyz0304360
中级用户
   稳
积分 257
发帖 123
注册 2008-1-5 来自 烟台
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
的确厉害
学习了
致敬
0字节的所有类型的文件
用FOR中的%%~z扩展文件大小
%%~zi=0就是0字节i
Indeed powerful
Learned
Salute
All types of files with 0 bytes
Use %%~z in FOR to expand the file size
%%~zi=0 means 0 bytes i
|

路 是自己选的
学习 是为了具备解决问题的能力 |
|
2008-2-23 11:33 |
|
|
zyz0304360
中级用户
   稳
积分 257
发帖 123
注册 2008-1-5 来自 烟台
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
请问
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul
中
"l:\"
这个是什么意思啊?
这里我不懂,能指点一下吗?
十分感谢
What does "l:\" mean in the following?
I don't understand here, can you give me some guidance?
Thank you very much
|

路 是自己选的
学习 是为了具备解决问题的能力 |
|
2008-2-23 11:40 |
|
|
cad55
高级用户
   
积分 620
发帖 329
注册 2007-12-5
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by zyz0304360 at 2008-2-23 11:40 AM:
请问
for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul
中
"l:\"
这个是什么意思啊?
这里我不懂, ...
晕
是要删文件夹的当前盘符.......
哪个0字节..你再说说.....
没有听懂..........
Originally posted by zyz0304360 at 2008-2-23 11:40 AM:
May I ask
In the line "for /f "tokens=*" %%a in ('dir /b /ad /s "l:\"^|sort /r') do rd "%%a" 2>nul ",
what does the part "l:\" mean?
I don't understand this part here...
Dizzy
It's to delete the folders in the current drive letter.......
The 0-byte one.. you can say it again.....
I didn't understand it..........
|
|
2008-2-23 12:16 |
|
|
abcd
银牌会员
    
积分 1436
发帖 739
注册 2007-10-11
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
就是利用rd命令的特性,在删除0字节文件夹时不会提示出错
It is to use the characteristics of the rd command. When deleting a 0-byte folder, it will not prompt an error.
|
|
2008-2-23 13:01 |
|
|
zyz0304360
中级用户
   稳
积分 257
发帖 123
注册 2008-1-5 来自 烟台
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "tokens=*" %%i in ('dir /b *.* ^|sort /r') do if %%~zi==0 del /f /q "%%~ni.*"
pause
Last edited by zyz0304360 on 2008-2-23 at 01:18 PM ]
@echo off
for /f "tokens=*" %%i in ('dir /b *.* ^|sort /r') do if %%~zi==0 del /f /q "%%~ni.*"
pause
Last edited by zyz0304360 on 2008-2-23 at 01:18 PM ]
|

路 是自己选的
学习 是为了具备解决问题的能力 |
|
2008-2-23 13:05 |
|
|
zyz0304360
中级用户
   稳
积分 257
发帖 123
注册 2008-1-5 来自 烟台
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by cad55 at 2008-2-23 12:16 PM:
晕
是要删文件夹的当前盘符.......
哪个0字节..你再说说.....
没有听懂..........
是要删文件夹的当前盘符.......
我执行
dir /b /ad /s "|:\"
就会报错
找不到指定路径啊
比如有这样一个文件
C:aa\aa\aa
盘符是怎么删的?
这样?
C:aa\aa\aa |:\
我是菜鸟,目前只懂这个
set a=C:aa\aa\aa
set a=%a:\=%
上面的不懂还请指点,谢谢了
Originally posted by cad55 at 2008-2-23 12:16 PM:
Wow
It's to delete the current drive letter of the folder.......
Which 0-byte.. you say again.....
Didn't understand..........
It's to delete the current drive letter of the folder.......
I execute
dir /b /ad /s "|:\"
and it will report an error
Cannot find the specified path ah
For example, there is such a file
C:aa\aa\aa
How to delete the drive letter?
Like this?
C:aa\aa\aa |:\
I'm a newbie, currently only understand this
set a=C:aa\aa\aa
set a=%a:\=%
The above is not understood, please give guidance, thank you
|

路 是自己选的
学习 是为了具备解决问题的能力 |
|
2008-2-23 13:26 |
|
|
duansuo
新手上路

积分 4
发帖 2
注册 2008-2-2
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
有没有人能完整的解释下啊,还是有点不懂啊
谢谢拉!
Is there anyone who can explain it completely? I still don't quite understand. Thanks a lot!
|
|
2008-2-23 15:07 |
|
|
abcd
银牌会员
    
积分 1436
发帖 739
注册 2007-10-11
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by zyz0304360 at 2008-2-23 01:26 PM:
是要删文件夹的当前盘符.......
我执行
dir /b /ad /s "|:\"
就会报错
找不到指定路径啊
比如有这样一个文件
C:aa\aa\aa
盘符是怎么删的 ...
把"|:\"
去掉就表示当前盘符
把"|:\"替换为自己的路径即可
Originally posted by zyz0304360 at 2008-2-23 01:26 PM:
It is to delete the current drive letter of the folder.......
I execute
dir /b /ad /s "|:\"
and it will report an error
Cannot find the specified path.
For example, there is such a file
C:aa\aa\aa
How to delete the drive letter...
Removing "|:\" means the current drive letter.
Replace "|:\" with your own path.
|
|
2008-2-23 16:50 |
|
|
cad55
高级用户
   
积分 620
发帖 329
注册 2007-12-5
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by duansuo at 2008-2-23 03:07 PM:
有没有人能完整的解释下啊,还是有点不懂啊
谢谢拉!
比如:你要删C盘下.空文件夹:
for /f "tokens=*" %%a in ('dir /b /ad /s "c:\"^|sort /r') do rd "%%a" 2>nul
你要删d盘下.空文件夹:
for /f "tokens=*" %%a in ('dir /b /ad /s "d:\"^|sort /r') do rd "%%a" 2>nul
Last edited by cad55 on 2008-2-23 at 05:14 PM ]
Originally posted by duansuo at 2008-2-23 03:07 PM:
Is there anyone who can explain it completely? I still don't understand it very well.
Thanks!
For example: You want to delete empty folders under the C drive:
for /f "tokens=*" %%a in ('dir /b /ad /s "c:\"^|sort /r') do rd "%%a" 2>nul
You want to delete empty folders under the D drive:
for /f "tokens=*" %%a in ('dir /b /ad /s "d:\"^|sort /r') do rd "%%a" 2>nul
Last edited by cad55 on 2008-2-23 at 05:14 PM ]
|
|
2008-2-23 17:04 |
|
|
Nickey
初级用户
 
积分 132
发帖 59
注册 2007-8-23 来自 GuangZhou
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
为什么将2#的
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
改为:
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do echo "%%a">>空文件夹菜单.txt
写入记事本的却是所有文件夹呢?
Why does changing the
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
to:
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do echo "%%a">>空文件夹菜单.txt
result in all folders being written to the notepad?
|

I could be the one
http://kanlis.7ta.cn |
|
2008-2-23 17:15 |
|
|
abcd
银牌会员
    
积分 1436
发帖 739
注册 2007-10-11
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Originally posted by Nickey at 2008-2-23 05:15 PM:
为什么将2#的
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
改为:
for /f "tokens=*" %%a in ( ...
'dir /b /ad /s "E:\"^|sort /r'
是会列出所有文件夹的,至于为什么只删除空的文件夹而不删除非空文件夹
就是利用rd命令的特性,在删除空文件夹时不提示
在未加/Q参数时,rd命令在删除非空文件夹时,会提示出错信息的。
Originally posted by Nickey at 2008-2-23 05:15 PM:
Why change the
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
to:
for /f "tokens=*" %%a in ( ...
'dir /b /ad /s "E:\"^|sort /r'
will list all folders. As for why it only deletes empty folders and not non-empty ones
it is because of the characteristic of the rd command. When deleting an empty folder, it does not prompt
When the /Q parameter is not added, the rd command will prompt an error message when deleting a non-empty folder.
|
|
2008-2-23 17:18 |
|
|
zyz0304360
中级用户
   稳
积分 257
发帖 123
注册 2008-1-5 来自 烟台
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by Nickey at 2008-2-23 05:15 PM:
为什么将2#的
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
改为:
for /f "tokens=*" %%a in ( ...
'dir /b /ad /s "E:\"^|sort /r'
此命令用于列出所有E盘下及其子目录(/s)的文件夹名(/ad)
/ad指定了打印文件夹名
然后把文件夹名赋值给%%a
2>nul
的意思是把rd "%%a"命令执行时出现的错误命令写入空设备(就是不需要反馈了)
改成 echo "%%a" >>aaa.txt
当然就是把删除空文件时的系统反馈写入aaa.txt
因为%%a就是文件夹名
Last edited by zyz0304360 on 2008-2-23 at 06:07 PM ]
Originally posted by Nickey at 2008-2-23 05:15 PM:
Why change the
for /f "tokens=*" %%a in ('dir /b /ad /s "E:\"^|sort /r') do rd "%%a" 2>nul
to:
for /f "tokens=*" %%a in ( ...
'dir /b /ad /s "E:\"^|sort /r'
This command is used to list all folder names (with /ad) under and in subdirectories (/s) of drive E:
/ad specifies to print folder names
Then assign the folder name to %%a
2>nul
means to write the error commands when executing the rd "%%a" command to the null device (that is, no feedback is needed)
Changing it to echo "%%a" >>aaa.txt
Of course, it is to write the system feedback when deleting empty files to aaa.txt
Because %%a is the folder name
Last edited by zyz0304360 on 2008-2-23 at 06:07 PM ]
|

路 是自己选的
学习 是为了具备解决问题的能力 |
|
2008-2-23 18:06 |
|