'Whereis' command in Windows Vista searches a file in directory included in 'path' environment variable. We can write a batch file that will emulate 'whereis' command as in Windows Vista. Below is a batch script which searches specified file on system drive. This script is slower as it searches entire system drive for file unlike whereis command in Vista and lists every instance of file with it's attributes.
Write 'whereis' emulator:
Open a notepad, copy and paste the presented whereis.bat code in it. save it as 'whereis.bat'.
if not "%~0"=="%~0%~1" goto firsttime
echo help: type 'whereis filename' to run command
echo Don't run whereis on more than one cmd at a time.
if "%~1"=="/?" goto help
cd /d %temp%
for /f "tokens=* " %%i in (file.txt) do set filename=%%~i
echo Searching "%filename%" on %systemdrive% drive(System drive).
dir /a:-d /b /s|find /I "%filename%">%temp%\temp2.txt
for /f "tokens=* " %%i in (temp2.txt) do if /I "%filename%"=="%%~nxi" attrib "%%~i"
for /f "tokens=* " %%i in (temp1.txt) do cd /d "%%~i"
Possible attributes for a file:
How To Use:
Open the folder where you saved the 'whereis.bat', right click on the file and Send To-> Command Prompt Here (We have seen how to add 'Command Prompt Here' option to 'Send To' in previous post. See 'Command Prompt Here'). It will open the command prompt at parent folder.Type
A H c:\dir\file.ext
Above output tells that file.exe is present in
- C: drive and is hidden.
- C:\dir and is archived and hidden.
You can modify this script to search a file on other drive. Just place the drive letter before cd\ command in bat file. The file also provides help regarding uses if you type whereis /?.
Leave a comment