|
liuwushu
初级用户
 
积分 93
发帖 35
注册 2006-12-20
状态 离线
|
『楼 主』:
(求助)关于批处理搜索文件的请教,谢谢!
使用 LLM 解释/回答一下
如何用批处理写在搜索指定文件后,打开文件所在的文件夹。
........输入要搜索的文件名:
.......正在搜索中请稍等......
打开文件所在的文件夹
How to use batch processing to open the folder where the file is located after searching for the specified file.
........Enter the file name to search for:
.......Searching, please wait......
Open the folder where the file is located
|
|
2006-12-21 16:16 |
|
|
echo
初级用户
 
积分 148
发帖 69
注册 2006-11-23
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
试试这个吧:
注意文件比较多的话估计会让你机器够呛的!!
for /r %%i in (*.bat) do start %cd:~0,2%%%~pi
Try this:
Note that if there are many files, it may make your machine work hard!!
for /r %%i in (*.bat) do start %cd:~0,2%%%~pi
|
|
2006-12-21 23:49 |
|
|
liuwushu
初级用户
 
积分 93
发帖 35
注册 2006-12-20
状态 离线
|
|
2006-12-22 05:46 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
可以先用tree做各分区的目录数,保存到莫个指定文本,然后在文本中搜索文件
First, use tree to make a directory count for each partition and save it to a specified text, then search for files in the text.
|
|
2006-12-22 06:17 |
|
|
tianzizhi
高级用户
   
积分 622
发帖 214
注册 2006-9-22
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
@echo off
set /p a=请输入要搜索文件(要加扩展名):
echo 正在搜索中,请稍等.........
for %%i in (c d e f g h) do @(
for /f %%j in ('dir %%i:\%a% /s/a/b') do start %%~pj
)
@echo off
set /p a=Please enter the file to search (including extension):
echo Searching, please wait.........
for %%i in (c d e f g h) do @(
for /f %%j in ('dir %%i:\%a% /s/a/b') do start %%~pj
)
|
|
2006-12-22 06:18 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
请问你要查找的文件到处都有还是只有一个?
若是具有唯一性,下面的代码应该可以(抄自lxmxn):
@echo off
set/p input=请输入要查询的文件名
for %%i in (c d e f) do (
for /f "delims=" %%a in ('dir /s/b/a-d %%i:\%input% 2^>nul') do (
start %%~dpsa&&goto :eof
)
)
Do you want to find the file everywhere or only in one place?
If it is unique, the following code should work (copied from lxmxn):
@echo off
set/p input=Please enter the file name to query
for %%i in (c d e f) do (
for /f "delims=" %%a in ('dir /s/b/a-d %%i:\%input% 2^>nul') do (
start %%~dpsa&&goto :eof
)
)
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-22 06:26 |
|
|
liuwushu
初级用户
 
积分 93
发帖 35
注册 2006-12-20
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
谢谢tianzizhi,还有个问题,用你的方法,
不能实现全盘搜索,只能把bat放到那个盘符就搜索那个盘的文件。
不会打开C:\Program Files文件夹,只会打开C盘。
Thanks tianzizhi, there is another question. With your method, it cannot achieve full-disk search, only search the files in the drive where the bat is placed. It won't open the C:\Program Files folder, only the C drive.
|
|
2006-12-22 06:50 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
~~~>_<~~~
试试我的......
~~~>_<~~~
Try my......
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-22 06:54 |
|
|
liuwushu
初级用户
 
积分 93
发帖 35
注册 2006-12-20
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
ccwan的方法也不行,你不相信把BAT放到桌面,看看能不能找到D盘文件!
The method of ccwan doesn't work either. If you don't believe it, put the BAT on the desktop and see if you can find the files on drive D!
|
|
2006-12-22 06:54 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
我试过好多次了,可以啊!
你找什么文件打不开d:?
I've tried many times, it's okay!
What file are you looking for that can't be opened on d:?
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-22 06:56 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
其实这个批处理还可以改动一下,比如你要找1.txt,但是机子里有3~5个,那就把代码中 &&goto :eof 去掉,有几个1.txt打开几个文件夹,若你不嫌烦人的话.^_^
In fact, this batch processing can still be modified. For example, if you want to find 1.txt but there are 3 to 5 in the computer, then remove &&goto :eof in the code. There will be as many 1.txts as there are folders opened. If you don't mind being tedious. ^_^
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2006-12-22 07:11 |
|
|
tao0610
高级用户
    朦胧的世界
积分 579
发帖 218
注册 2006-10-24
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
对ccwan的修改一下,支持有空格的文件名.
@echo off
set/p input=请输入要查询的文件名:
for %%i in (c d e f) do (
for /f "usebackq delims=" %%a in (`dir/s/b/a-d "%%i:\%input%" 2^>nul`) do (
start %%~dpsa
)
)
Modify the modification of ccwan to support file names with spaces.
@echo off
set/p input=Please enter the file name to query:
for %%i in (c d e f) do (
for /f "usebackq delims=" %%a in (`dir/s/b/a-d "%%i:\%input%" 2^>nul`) do (
start " " "%%~dpsa"
)
)
|

认识自己,降伏自己,改变自己,才能改变别人! |
|
2006-12-22 07:26 |
|
|
liuwushu
初级用户
 
积分 93
发帖 35
注册 2006-12-20
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
谢谢tao0610,这个是我要的,又学习了。
Thanks tao0610, this is what I need, and I've learned something again.
|
|
2006-12-22 08:38 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
怎么start 都不加空格那?
Why is there no space after "start"?
|
|
2006-12-22 09:00 |
|