Search
Moderator: DosItHelp
Search
Hi everybody, i am new and i'm from Poland so sorry for my language and spelling mistakes. Can you talk how to do .bat with searching function. This batch must search folders or files for example if i write Test.txt it will find track C:\Users\user\Desktop\Test.txt Do you know how to build it ?
Re: Search
Code: Select all
C:\>dir /a-d /b /s test.txt
C:\Users\Squash\Desktop\Test.txt
C:\>
Re: Search
Velpreso wrote:Doesn't work as i want
Your comment really isn't useful to solving your problem. If something isn't working the way you want it too then you probably didn't explain what you wanted clearly enough.
Re: Search
I look for script who will find source code when i write test.txt it will search hard drive and show me source code to this file.
Re: Search
Velpreso wrote:I look for script who will find source code when i write test.txt it will search hard drive and show me source code to this file.
You need to be exact in your explanation to get a batch file that is appropriate.
I think you are saying that you want a batch file called search.bat and you want to type
search test.txt
and it will search drive c: and open the file test.txt in notepad. Is that right?
Re: Search
No . FOR EXAMPLE if i write test.txt in .bat it will be look for test.txt in hard drive and if find test.txt it will show me that test.txt was saved in C:\user\deskop or for example in D:\Downloads. In my view it should be build with function FOR.
Re: Search
Squashman gave you the code that does that.
Here it is in a batch file - call it search.bat and then type
search test.txt
Here it is in a batch file - call it search.bat and then type
search test.txt
Code: Select all
@echo off
searching for "%~1"
dir /a-d /b /s "c:\%~1" "d:\%~1"
pause