Welcome, guest | Sign In | My Account | Store | Cart

Quick search on files index embedded directly in the command script. For example: "search.cmd exe$" - looks for all EXE files in index or just "search.cmd blahblahblah" - looks for all matches with "blahblahblah" in paths. To remove index from script use "search.cmd /fix:me" command (without quotes).

Batch, 30 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@echo off
  setlocal
    if "%1" equ "/fix:me" (
      call:fix
      echo.::not_indexed>>"%~dpnx0"
      goto:eof
    )
    for /f "tokens=* delims=:" %%i in ('findstr "^::" "%~dpnx0"') do (
      if "%%i" equ "not_indexed" (
        call:fix
        for /f "tokens=*" %%i in ('mountvol ^| findstr /r \:\\$') do (
          (2>nul dir %%i /s /b & 2>nul dir /a:h /s /b)>>"%~dpnx0"
        )
      )
    )
    if "%1" neq "" (
      for /f "tokens=*" %%i in ('findstr /i /r /c:%1 "%~dpnx0"') do (
        if exist "%%i" echo %%i
      )
    )
    goto:eof
  :fix
    for /f "tokens=* delims=" %%i in ('mountvol^
     ^| findstr /v /b /i /r /c:[a-z]:\\ /c::: "%~dpnx0"') do (
      echo.%%i>>source.tmp
    )
    move /y source.tmp "%~dpnx0"
  endlocal
exit /b
::not_indexed
Created by greg zakharov on Tue, 20 Aug 2013 (MIT)
Batch recipes (42)
greg zakharov's recipes (59)

Required Modules

  • (none specified)

Other Information and Tasks