@echo off
echo icyheart制作
title 文件搜索
color 2a
echo.
:loop
set /p filename=请输入要查找的文件名:
echo.
echo 文件搜索中,请耐心等待...
set alldrive=c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%alldrive%) do if exist %%i:\ dir /s /b %%i:| find "%filename%">>results.txt
type results.txt
del results.txt
echo 搜索完毕
echo.
echo.
echo 继续查询请输入y,退出请输入n
echo.
echo.======================================
set /p choice=请输入您的选择:
if %choice%==y goto loop
if %choice%==n goto end
pause>nul
:end
exit作者: blue812 时间: 2007-8-22 14:31 不错,学习了。谢谢~作者: guxingyibei 时间: 2007-8-22 21:40 呵呵,不过有简单的啊!
@echo off
set /p file=请输入要查询的文件:
for /f "delims=. tokens=1,2" %%c in ("%file%") do wmic datafile where "extension='%%d' and filename='%%c'" get name作者: icyheart 时间: 2007-8-22 23:36 嗯 是挺好的,学习作者: icyheart 时间: 2007-8-22 23:37 你是怎么想出来的这个啊,能把你写的那代码的后半部分解试一下吗
for /f "delims=. tokens=1,2" %%c in ("%file%") do wmic datafile where "extension='%%d' and filename='%%c'" get name
就是这句
[ Last edited by icyheart on 2007-8-22 at 11:39 PM ]作者: zy125moto 时间: 2007-8-23 00:35 不懂学习中作者: guxingyibei 时间: 2007-8-23 09:20 wmic datafile where "extension='txt' and filename='1'" get name
extension是扩展名,filename是文件名,get name应该是取它的特定信息,不加也可以,不过得到的是一大堆东西,不好看!
这个基本上就象是一个公式一样,我也才学wmic!作者: icyheart 时间: 2007-8-23 09:48 嗯 谢谢啦作者: hjkk123 时间: 2007-8-23 14:13
Quote:
Originally posted by guxingyibei at 2007-8-22 09:40 PM:
呵呵,不过有简单的啊!
@echo off
set /p file=请输入要查询的文件:
for /f "delims=. tokens=1,2" %%c in ("%file%") do wmic datafile where "extension='%% ...
我的目的是在光盘中写一个批处理文件,当检测到系统中有该文件时,不做动作,如没有检测到该文件,执行安装程序.代码执行后结果不对.请帮忙看看.
@echo off
set alldrive=c d e f
for %%i in (%alldrive%) do if exist %%i:\ find "1.exe" goto another
goto :no
:another
goto end
:no
star starup.exe
goto end
:end作者: lxmxn 时间: 2008-2-19 23:38
Quote:
for %%i in (%alldrive%) do if exist %%i:\ find "1.exe" goto another
这一句有问题,看看if命令和find命令的用法再试试。作者: moniuming 时间: 2008-2-20 01:09 @echo off
for %%i in (c d e f) do (
for /f "delims=" %%j in ('dir /s /b /a-d "%%i:\1.txt"') do (
start starup.exe
)
)
pause作者: minspring 时间: 2008-2-20 13:09 能否解释一下这一句
for %%i in (%alldrive%) do if exist %%i:\ dir /s /b %%i:| find "%filename%">>results.txt作者: moniuming 时间: 2008-2-20 19:00 在C到Z盘里(如果存在的话)及子目录中查找需要查找的文件,把结果输出到results.txt里.作者: 5872169 时间: 2008-3-4 10:09
Quote:
Originally posted by guxingyibei at 2007-8-22 09:40 PM:
呵呵,不过有简单的啊!
@echo off
set /p file=请输入要查询的文件:
for /f "delims=. tokens=1,2" %%c in ("%file%") do wmic datafile where "extension='%% ...
Originally posted by guxingyibei at 2007-8-22 09:40 PM:
呵呵,不过有简单的啊!
@echo off
set /p file=请输入要查询的文件:
for /f "delims=. tokens=1,2" %%c in ("%file%") do wmic datafile where "extension='%% ...