Any Pro' know how to make a code in batch file to "find or search a file in your computer?
I give up searching in google but still can't find any solution with it.
Tnx advance.
[Help]Finding or Searching File in your own Computer.
Moderator: DosItHelp
-
- Posts: 1
- Joined: 10 Mar 2010 12:05
Re: [Help]Finding or Searching File in your own Computer.
Maybe something like that:
It's looking for "example.txt" on drive C:. Note that it needs a lot of time.
Code: Select all
@echo off &setlocal
set filename=example.txt
pushd c:\
for /f "delims=" %%a in ('dir /a-d /b /s "%filename%"') do set "fullname=%%a" &set "filepath=%%~dpa"
popd
echo %fullname%
echo %filepath%
pause
It's looking for "example.txt" on drive C:. Note that it needs a lot of time.
Re: [Help]Finding or Searching File in your own Computer.
I doubt if I am a pro, but here is a solution anyway using biterscripting.
To search for a file
lf -r -n -g "*example*" "C:/somefolder"
will show all files matching the pattern "example*" under the folder tree at "C:/somefolder".
To search for a string within the contents of files
script SS_FindStr.txt str("today") files("*.txt") dir("C:/somefolder")
will display all files matching the pattern "*.txt" containing the search string "today" under the folder tree at "C:/somefolder". It will show this output.
File: C:/somefolder/savedemails/986AC98DF09.txt
Line 34: Today is a good day to start the new project.
File: C:/somefolder/dailyreport.txt
Line 7: Daily report for today: March 10, 2010
.
.
.
If you want to search for regular expressions, use the script SS_FindRE.txt instead.
I use these to search the contents of my emails. You can find some more useful stuff at http://www.biterscripting.com .
To search for a file
lf -r -n -g "*example*" "C:/somefolder"
will show all files matching the pattern "example*" under the folder tree at "C:/somefolder".
To search for a string within the contents of files
script SS_FindStr.txt str("today") files("*.txt") dir("C:/somefolder")
will display all files matching the pattern "*.txt" containing the search string "today" under the folder tree at "C:/somefolder". It will show this output.
File: C:/somefolder/savedemails/986AC98DF09.txt
Line 34: Today is a good day to start the new project.
File: C:/somefolder/dailyreport.txt
Line 7: Daily report for today: March 10, 2010
.
.
.
If you want to search for regular expressions, use the script SS_FindRE.txt instead.
I use these to search the contents of my emails. You can find some more useful stuff at http://www.biterscripting.com .