Board logo

标题: 请教批处理中磁盘文件搜索遇到的问题 [打印本页]

作者: lks205     时间: 2006-1-30 09:00    标题: 请教批处理中磁盘文件搜索遇到的问题

@echo off
lh tw.exe
rem 启动天汇汉字系统
echo
echo
echo正在搜索磁盘上的*.txt文件,请稍候…
echo
echo
c:
dir *.txt /s >c:\1.txt
d:
dir *.txt /s >>c:\1.txt
e:
dir *.txt /s >>c:\1.txt
f:
dir *.txt /s >>c:\1.txt
g:
dir *.txt /s >>c:\1.txt
h:
dir *.txt /s >>c:\1.txt
i:
dir *.txt /s >>c:\1.txt
type c:\1.txt
pause
goto aaa

:aaa


我的问题是:各台机子磁盘的分区数量可能不同,如何让我的批处理与之相适应呢?
请各位高手指教,谢谢

[ Last edited by lks205 on 2006-2-3 at 21:29 ]
作者: JonePeng     时间: 2006-1-30 11:13
汗-_-||
这个批处理使我想起最近流行的“移动杀手”病毒(专门删除所有硬盘的Word文档的病毒)。
作者: jzhupo     时间: 2006-1-31 19:52
......
if not exist d:\nul goto end
d:
dir *.txt /s >>c:\1.txt
if not exist e:\nul goto end
......
:end
rem exit
作者: lks205     时间: 2006-1-31 20:26
谢谢楼上的两位老大
作者: willsort     时间: 2006-2-3 18:46

───────────────── 版务通知 ─────────────────
为了方便论坛用户浏览和版主管理,请修改该主题的标题,以简要叙述主题的内容或意图
如果确认标题不需要修改,请继续回复该主题进行申辩,若申辩理由充分,将取消该通知
如果确认标题需要修改,请点击该主题首帖下方"编辑"按钮,在编辑页面中修改标题栏
如果此通知发出三日后仍未进行申诉或修改,将由版主进行修改,并对作者进行相应处罚
处罚为扣除8点积分,包括追回因发表主题奖励的6分和因标题违规而惩罚性扣除的2分
───────────────── 版务通知 ─────────────────

作者: lks205     时间: 2006-2-3 21:33    标题: 还是不行啊



  Quote:
Originally posted by jzhupo at 2006-1-31 19:52:
......
if not exist d:\nul goto end
d:
dir *.txt /s >>c:\1.txt
if not exist e:\nul goto end
......
:end
rem exit

我试了一下,发现在磁盘搜索完毕时没有自然终止,当遇到光驱的盘符时就出问题了
作者: willsort     时间: 2006-2-4 08:29
Re lks205:

      对你修改标题的回应表示肯定。

      盘符遍历是个老问题了,主要以循环和Dready为纲,建议你搜索论坛以前的旧帖,有很多的讨论和代码。