[Batch] Search bulk files

Source: Internet
Author: User

Introduction

Two days ago, should be a senior request to his dorm to see him graduation design problems
It turned out that he had downloaded the CRM system from the Internet to compile all compiled, but not to talk about the operation of the problem
Look at the main is that the system used a lot of open source third-party control library, and download the time is not, you need to find
His computer has a part of the DLL, but also missing part, the key is that he is a lot worse, a total lack of nearly 20 DLLs
And in his computer a part of the DLL can not find where, looked for a long time did not find, so I said I write to you from the overall to find it,
Then proceed to do, found problems, eventually did not make, make very face, go back to the dorm to study the next rewrite a complete, now put out

Briefly

The feature of this batch is that you can search for a group of filenames at the same time
Full search Windows itself comes with itself (Win+f is a full search), but only one file can be searched, and multiple files cannot be searched at the same time
That's why there's a problem with this batch.

How to use

Select the search mode first, different search mode results show different, but the result is exactly the same
Mode 1 for 1-3 files
Mode 2 for more than 3 files

Search Mode 1:



Then enter a set of file names to search for
For example, I want to search for compressed files starting with REC and compressed files starting with HD spaces.
each filename to be searched is separated by a/symbol


You can see that there are no files in the C-drive E-drive that match this condition.
At the same time I saw a file that met these two conditions.


Search Mode 2:

Just saw the results of search Mode 1 show
is to list all eligible files together, without order, in order because the resulting file is less
If a large number of eligible, there is no order to say, all the simultaneous search for multiple files is not conducive to viewing results, so there is a search mode 2
Mode 2 is a separate list of each file under each disk, rather than a list of all the files under this disk.


This graph can be used to understand the Mode 2 search method very well.
The results of each file to be searched are listed separately

Batch code, save to bat file to run:

@echo off&title Full Search batch file small sea 2012-3-6setlocalenabledelayedexpansionREMfilter, to search for a set of files, each file with/symbol separated, example: Rec*.rar/hd *.rarSetFilter=REMSub-filters for temporary filters to search for files under each partitionSetsubf=SetVolume=REMMode 1 uses a block of files to be searched in each partition, without orderREMMode 2 uses each file that is displayed in each partition to be searched separately: ChooseEcho******** full search for batch files *******Echo┏━━━━━━━━━━━━━━┓Echo┃ mode [1]: For searching for a small number of files ┃Echo┃ mode [2]: For searching for a large number of files ┃Echo┗━━━━━━━━━━━━━━┛EchoPlease select a search mode:Setchoose=n&Set/P choose=if  not%choose%==1 (if  not%choose%==2CLS&GotoChoose: FilterREMprompt to be manually entered by the user if the filter is not defined beforehandif"%filter%" = = "" (Echo┏━━━━━━━━━━━━━━━━━━━━━━━┓Echo┃ separate each file with a/symbol, such as a*b.txt/d?e.*┃Echo┃ support wildcards? and *, do not include other special symbols ┃Echo┗━━━━━━━━━━━━━━━━━━━━━━━┛EchoPlease enter the batch file to search for:Setfilter=n&Set/P filter=if"!filter!" = = "N" (Setfilter=&CLS&Goto : Filter)SetFilter=!filter: "=!) REM If you use mode 1, you need to fix the filter to mode 1 supported form REM Mode 1 use the dir command to bring in the bulk file feature, in the form of double quotation marks for each file and separated by a space, example"A*.*" "E?f.doc"if%choose%==1 (set filter="!filter:" =! "SetFilter=!filter:/= ""!) for/F "tokens=3"%%i in ('EchoList Volume ^| DiskPart ^| findstr "Disk Partition" ') Do(SetVolume=%%iif%choose%==1 (Echo.&Echo┃Echo┃ looking for ^<!filter!^> file under ^<!volume!^> disk ...Echo┗━━━━━━━━━━━━━━━━━━━━━━━━━━━CD/d "!volume!:\ " Dir!filter!    /s/b/a) else if%choose%==2 (set subf=!filter! If not"!subf!" = = "" (Call:mode2 "!filter!"else echo-^> start looking for the next partition) Echo.&echo.echo┏━━━━━━━━━┓echo┃ Search complete!! ┃echo┗━━━━━━━━━┛rem in the set filter= behind and the & symbol can not have spaces, no space is to remove the filter variable, there is a space is given a space echo press any key to return Pause>nul & set Filter =& CLS & Goto Choose:mode2rem%0 is the function name itself: mode2,%1 is the value passed,%~1 to delete the double quotes in the variable"SetSubf=%~1REMin this sub-search function, the filter is separated by/symbol and the first value of the split is obtained .REMThe remaining value of the partition is then re-assigned to the filter and called itself until the filter is empty, returning for/F "tokens=1,* delims=/"%%j in ("%subf%") Do(Echo.&Echo┃Echo┃ looking for ^<%%j^> file under ^<!volume!^> disk ...Echo┗━━━━━━━━━━━━━━━━━━━━━━━━━━━dir"!volume!:\" " %%j "/s/b/A set subf=%%k) if not"!subf!" = = "" (Call%0 "!subf!") goto:eof
View Code

--Originally published in 2012-3-11 08:57

[Batch] Search bulk files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.