Searching in cmd
Solved/Closed
persiansushiant
-
Jan 31, 2010 at 01:17 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jan 31, 2010 at 04:14 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Jan 31, 2010 at 04:14 PM
Related:
- Searching in cmd
- Change computer name cmd - Guide
- Steam cmd download - Download - Gaming tools
- Clear ram cmd - Guide
- Cmd message to another computer - Guide
- Google searching in another country - Guide
6 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jan 31, 2010 at 04:14 PM
Jan 31, 2010 at 04:14 PM
if the 4 points i said were correct. then first the batch file needs to be called "search.bat" as you are typing Search.
The other thing is that the search.bat file should be in the same folder from where you are trying to run it. Other option would be the have the path where the search.bat resides added the environment variable "PATH"
One change to the code is needs as it seems that you are passing two parameters. One the director and the other the the characters of the file
Save the code below Search.bat in your root c:\
once save, type cmd
then type cd /d c:\
then run search file
example
search "c:\windows" "sys"
REM search.bat
@ECHO OFF
cls
set folder=%~1
set str=%folder:~-1%
if %str%==\ GOTO MoveOn
set folder=%~1\
:MoveOn
set files=*%~2*
set searchFor="%folder%%files%"
dir /a-d %searchFor%
The other thing is that the search.bat file should be in the same folder from where you are trying to run it. Other option would be the have the path where the search.bat resides added the environment variable "PATH"
One change to the code is needs as it seems that you are passing two parameters. One the director and the other the the characters of the file
Save the code below Search.bat in your root c:\
once save, type cmd
then type cd /d c:\
then run search file
example
search "c:\windows" "sys"
REM search.bat
@ECHO OFF
cls
set folder=%~1
set str=%folder:~-1%
if %str%==\ GOTO MoveOn
set folder=%~1\
:MoveOn
set files=*%~2*
set searchFor="%folder%%files%"
dir /a-d %searchFor%
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jan 31, 2010 at 01:24 PM
Jan 31, 2010 at 01:24 PM
use dir command. To see what you can do with dir, use dir /? command
for your example
dir /a-d "C:\new folder\*s*"
for your example
dir /a-d "C:\new folder\*s*"
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jan 31, 2010 at 02:06 PM
Jan 31, 2010 at 02:06 PM
Not entirely clear about what you are want to accomplish. If just you want to run the command as a batch, you can simply type the same into the batch program and run it.
in case you want to hard code the dir
dir /a-d "c:\new folder\*s*"
In case you want to supply it as a parameter. In this case enclose the c:\new folder\*s* in the ". Say batch file is test.bat, then run it as test "c:\new folder\*s*"
dir /a-d %1
If you are trying to capture the result, you may want to pipe it to some file, like
dir /a-d "C:\new folder\*s*" > mysearch.txt
in case you want to hard code the dir
dir /a-d "c:\new folder\*s*"
In case you want to supply it as a parameter. In this case enclose the c:\new folder\*s* in the ". Say batch file is test.bat, then run it as test "c:\new folder\*s*"
dir /a-d %1
If you are trying to capture the result, you may want to pipe it to some file, like
dir /a-d "C:\new folder\*s*" > mysearch.txt
u didnt understand what i say i want to write in cmd "search c:\windows s"
i want to add command search to cmd and define it anything which has s in name.
i want to add command search to cmd and define it anything which has s in name.
Didn't find the answer you are looking for?
Ask a question
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jan 31, 2010 at 03:00 PM
Jan 31, 2010 at 03:00 PM
Well correct me where I am falling off.
1. you are using vista
2. when you say "cmd" you are talking about the command "cmd" that open a dos sort windows.
3. you would be typing in cmd and open the dos window
4. there you would be typing in command "search c:\windows s"
If that all is correct, then the command i gave you would work. Only thing that needs to be ensured is that the location of the path is where the cmd windows open or is available in the PATH
1. you are using vista
2. when you say "cmd" you are talking about the command "cmd" that open a dos sort windows.
3. you would be typing in cmd and open the dos window
4. there you would be typing in command "search c:\windows s"
If that all is correct, then the command i gave you would work. Only thing that needs to be ensured is that the location of the path is where the cmd windows open or is available in the PATH