cmd dir code example

Example 1: msdos dir for subdirectories

# Windows - cmd specific

# syntax 
dir /s <search-string>

# example (to find any files/folders with names containing "hoto", like Photo)
dir /s *hoto*

Example 2: dir files windows

# 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 3: dir files

# 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.

Tags:

Misc Example