search files using cmd code example

Example 1: find files in windows command

# For finding file use dir followed by string matching file name or regex
# pattern and add "/s" for searching recursively in subfolders:
dir /s "regex_or_file_name"
# For finding file contained in a searched directory use "/b":
dir /b "directory_name"
# Use respectively '/a-d' or '/ad' for finding only files or only folders.

Example 2: find name file in cmd

echo off
:start
cls

set /p input=masukan nama ? &
set result=| dir /a *.* /b | find "%input%"

echo %result%

pause
goto start

Tags:

Misc Example