中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-02 21:19
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » (Help) About batch processing file search, thanks!
Printable Version  1,736 / 13
Floor1 liuwushu Posted 2006-12-21 16:16
初级用户 Posts 35 Credits 93
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
Floor2 echo Posted 2006-12-21 23:49
初级用户 Posts 69 Credits 148
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
Floor3 liuwushu Posted 2006-12-22 05:46
初级用户 Posts 35 Credits 93
Is there a better way!
Floor4 wydos Posted 2006-12-22 06:17
中级用户 Posts 117 Credits 304
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.
Floor5 tianzizhi Posted 2006-12-22 06:18
高级用户 Posts 214 Credits 623
@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
)
Floor6 ccwan Posted 2006-12-22 06:26
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
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):

Floor7 liuwushu Posted 2006-12-22 06:50
初级用户 Posts 35 Credits 93
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.
Floor8 ccwan Posted 2006-12-22 06:54
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
~~~>_<~~~
Try my......
Floor9 liuwushu Posted 2006-12-22 06:54
初级用户 Posts 35 Credits 93
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!
Floor10 ccwan Posted 2006-12-22 06:56
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
I've tried many times, it's okay!
What file are you looking for that can't be opened on d:?
Floor11 ccwan Posted 2006-12-22 07:11
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
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. ^_^
Floor12 tao0610 Posted 2006-12-22 07:26
高级用户 Posts 218 Credits 579
Modify the modification of ccwan to support file names with spaces.

Floor13 liuwushu Posted 2006-12-22 08:38
初级用户 Posts 35 Credits 93
Thanks tao0610, this is what I need, and I've learned something again.
Floor14 vkill Posted 2006-12-22 09:00
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Why is there no space after "start"?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023