Page 1 of 1

Search

Posted: 28 Dec 2012 10:16
by Velpreso
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

Posted: 28 Dec 2012 10:23
by Squashman

Code: Select all

C:\>dir /a-d /b /s test.txt
C:\Users\Squash\Desktop\Test.txt

C:\>

Re: Search

Posted: 28 Dec 2012 11:16
by Velpreso
Doesn't work as i want :(

Re: Search

Posted: 28 Dec 2012 11:43
by Squashman
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

Posted: 29 Dec 2012 04:16
by Velpreso
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

Posted: 29 Dec 2012 04:30
by foxidrive
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

Posted: 29 Dec 2012 06:14
by Velpreso
No :P. 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

Posted: 29 Dec 2012 06:36
by foxidrive
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

Code: Select all

@echo off
searching for "%~1"
dir /a-d /b /s "c:\%~1" "d:\%~1"
pause

Re: Search

Posted: 29 Dec 2012 11:39
by Velpreso
Thanks guys.