Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active August 25, 2020 02:12
Show Gist options
  • Save paveljurca/6cd96f9b566d877e6677a7a55489115b to your computer and use it in GitHub Desktop.
Save paveljurca/6cd96f9b566d877e6677a7a55489115b to your computer and use it in GitHub Desktop.
@echo off
set $dir=%~1
set $regex=%~2
IF NOT DEFINED $regex set $regex=%$dir% & set $dir=.
dir "%$dir%" /b/s/a:|findstr /r /i "%$regex%"

windows search search-ms:displayname=search&crumb=location:c%3A%5CUsers%5Cpavel%5CDownloads%5C


forces regular expressions, so plain * won't work, but .* or just . will

f.bat ".avi$"

f.bat %windir%\system32\drivers "^VBox"

dir /b/s *word* can't specify root directory; always starts with the current directory.

To perform a system wide search

use where /r %systemdrive% budget.xls or dir /b/s/a: %systemdrive%\budget.xls to look for budget.xls.

doskey dirdir=dir /b/a:d $* to list directories only.

doskey dirfile=dir /b/a:-d $* to list files only.

To search inside text files use: findstr /s /i SOMETHING *.txt

Windows Desktop Search Engine: "Everything" http://voidtools.com/support/everything/searching/

which in Windows https://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-the-windows-command-line

wc -l in Windows (https://blogs.msdn.microsoft.com/oldnewthing/20110825-00/?p=9803/)

find vs ``findstr`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment