Helpful Batch File Search





Introduction: Helpful Batch File Search

About: just another ordinary guy who like experiments

This is my first instructable. so if I made a mistake please go easy on me.

I had made a simple batch file searcher, to help my self finding the files I need in my HDD jungle.
This batch is so much faster than standard windows search(windows button +f).

- Very fast
- easy to make.
- Portable (infact you can memorize all the commands)
- using it makes you look very cool. :D

- Limited to file name search only.
- must update data base regularly.
- update might took forever :)

I've searched instructable for similar batch file but found none.
That encourage me to make one.

Step 1: Getting Prepared

1. run cmd on Start->run, type in cmd, press enter.
2. create a new folder. (md anything)
3. add the new folder to your system path variable
control panel->system properties->advanced->environment variable->select path->edit->ok
4. check it on the command window by typing "path" followed by enter button.
5. explore to your new folder.
6. create two new text document.
7. rename one of them into update.
8. rename the other one into search.

Step 2: First Batch File

this is the content of the update.txt file
just copy and paste it into the update.txt

@title UPDATE
@del k:\finder\allfiles.log
@dir c:\ d:\ e:\ f:\ G:\ h:\ I:\ J:\ K:\ /s /a /b >> K:\finder\Allfiles.log

please edit the folder "K:\finder" into the folder name you just made.

save it

note :
you can add or remove the drive letter to suit your system.
the command above will be indexing file name from drive letter C to K.

Step 3: Second Batch File

This is the content of the second file
search .txt
just copy paste it.
@echo off
Title Search
echo use \.extension $ for seeking extenson of file ie:*.mp3
color 0a
findstr /I /L /A:FC "%1 %2 %3" k:\finder\allfiles.log |more

please edit the folder "K:\finder" into the folder name you just made.
save it.

Step 4: Rename the Text Document

go to your command prompt
ren *.txt *.bat
press enter
you should get 2 new batch file now instead of text document.

Step 5: Creating the Logs

now run the update.bat
and wait for..........quite some time.
relax it might took 5 to 15 minutes to finish.

after it got finished it will create new file called
a huge one :)

Step 6: Action

then you can run the search.bat file.
sample of usage

search update
search \.doc (for searching file extension)

more control:
press enter to get one line scrolling.
press space bar to get page scrolling.
press ctrl+c to quit searching.

since it already on your system path you can ran both search and update from any folder,
or even from the run command.

actually if you are an advanced user you can skip few step of this instructible.
hope it will became handy for you as it did for me.
thank you for reading.



    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest
    • Clocks Contest

      Clocks Contest

    We have a be nice policy.
    Please be positive and constructive.




    I want to make Batch file able to make and write to .txt files, then everytime I start it it searches for .txt files in the folder it is. How?

    This is really complicated. Maybe you could post a downloadable version of it...

    No wonder any of these work! They contain wrong Command Sets!!!

    1 reply

    I'm terribly sorry, but the grammar and spelling in this instructable was just terrible. I honestly couldn't understand a thing. Better luck next time.

    3 replies

     thank you, English is my second language. I think i did the best :(

    Oh, sorry! I didn't know. I didn't mean it like that, I though you were doing it on purpose! I thought you were purposely trying to make it like that, but I understand now. Oh, I'm really sorry! Please understand!

    :) no worries...
    You're not the only one and I did get that a lot...  so I get used to it... XD.  

    i know this is an older instructable but i was wondering if i could still get any help. I am trying to perform a search on my computer but instead of searching in a list of the file names, i want to find files on my computer that match the files names i give it, preferably line by line in a text file, example: file1.txt file5.exe lots_of_junk.html i can give this in a text file and have one file on every line of the text. next (which is where my problem is) is i need the computer to find the files that have the same name of the files given and copy, delete, or move them. the end result should be able to find the file anywhere on the system even if the file is hidden. If i need to elaborate on anything let me know, thx for the help

    4 replies

    i don't get what you're asking clearly so this is my guesses : 1. if you want to search for files in a given file name list. that is not possible to do in batch file. you'll need to write a program. phyton is free and easy to learn. 2. however you can create a list of specific file you want to look for by doing : (you'll have to do step 1-5 of this instructable first) search file1.txt >> file1.log search file5.exe >> file5.log search lots_of_junk.html >> lots_of_junk.log the new log file that created will only contain the result that matches the filename you've given. 3. to be able to do actions such as move copy delete of the search result you'll have to write a program for it. or simple yet just use that (windows key + f, if you had windows os) 4. the dir parameter i used on this instructable is able to find hidden and system files. hope that help :)

    #1 it can be in a given list, but it can also be in the program itself, i was trying to do an 'if exist' but the options of where it searches are limited # 2 seems like it will work, i will create this and try it on my computer and see how it works #s 3 and 4, well i would do that but, to elaborate on the purpose of the program i wish to write, this will be stealth-run on a friend's computer who copied the (dangerous) contents of my flash drive. he made copies to multiple computers and removable memory so im looking for a way to run an automated search that can find the location of the files and put them in a log (like #2 that you suggested) so i can delete them manually. i could have the program auto delete but if another file on the system is named the same as one of my files then it would also be deleted. and if he has renamed any of my files i want to know where the rest of them are. they will be hidden from the search is he renames them, but he copied my entire flash drive so he would be renaming for a long time and i know he won't rename them all because some of them are dependent upon other files. i already know how to get it on his computer and to run in stealth. also, does your program find and log hidden files? and can it find folders? thx for the help, again if you need any clarification just say so

    if the purpose you asking this is for retrieving "stolen" files... i guess you can do this by putting up the batch on your removable storage and use the autorun.inf to automatically run the batch once done... you have to go away from your friend "analyzing" the result log. once done, you will know where the targeted files are. you can retreive it manually or using software aid.  but once renamed it's hard to find file like that. 
    the dir command in the batch file are capable to find hidden files and folders. since it searches the string it will return any matched string whether that is a folder or a file.
    sorry for the long reply.

    no problem, i will probably retrieve it with software aid, and im only going to scan and log his C:\ drive, he always puts hidden stuff there because the large WINDOWS and system directories would make it hard to find manually, he has to use the .bat file extension so i will also search for that, he has although re-named every file that he copied so i will have to review alot of the results manually, which will take a very long time, but the names should stand out and seem out of place, thx for the help

    nevr mind i found it it was named differently

    im using vista and i cannot find the system properties in my control pannel...

    very nice you could have it set to run every night at 3 am

    3 replies

    hey i want to do this for my flash drive how do i get the dir command it know is drive letter

    just add the drive letter of your flash drive where it used to be mounted. To the update.bat. or remove all drive letter but your flash drive, to make it a flash drive indexer. be sure to plug the flash drive before you run update. or you end up getting "The system cannot find the path specified." as result.

    well im runing this for my flash dirve on my flash drive so i can use it on more then one pc i came up with this to slove my promble
    my updater
    echo drive letter:
    @set /p d=
    @title UPDATE
    @del k:\finder\allfiles.log
    dir k:\ /s /a /b >> D:\finder\Allfiles.log
    the finder
    @set /p d=
    echo drive letter:
    @echo off
    Title Search
    color 0a
    set /p str=
    findstr /I /L /A:FC %str% %d%:\finder\allfiles.log
    goto start

    oh yea do you know how to use if commands?