Welcome, guest | Sign In | My Account | Store | Cart
@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

Diff to Previous Revision

--- revision 1 2013-08-20 15:36:01
+++ revision 2 2013-10-10 16:18:09
@@ -1,35 +1,29 @@
 
@echo off
   setlocal
-    ::restore batch code
     
if "%1" equ "/fix:me" (
       call
:fix
       echo
.::not_indexed>>"%~dpnx0"
       
goto:eof
     
)
-    ::checking index marker
     
for /f "tokens=* delims=:" %%i in ('findstr "^::" "%~dpnx0"') do (
       
if "%%i" equ "not_indexed" (
-        ::removing not_indexed flag
         call
:fix
-        ::building database
-        for /f "tokens=*" %%i in ('mountvol ^| findstr /r /c::\\$') do (
-          2>nul dir %%i /s /b >> "%~dp0index.db"
-          2>nul dir %%i /a:h /s /b >> "%~dp0index.db"
+        for /f "tokens=*" %%i in ('mountvol ^| findstr /r \:\\$') do (
+          (2>nul dir %%i /s /b & 2>nul dir /a:h /s /b)>>"%~dpnx0"
         
)
-        ::storing index into batch
-        1>nul copy /a "%~dpnx0"+"%~dp0index.db" "%~dpnx0"
-        ::removing index file
-        del /f /q "%~dp0index.db"
       
)
     
)
     
if "%1" neq "" (
-      for /f "tokens=*" %%i in ('findstr /i /r /c:%1 "%~dpnx0"') do if exist "%%i" echo %%i
+      for /f "tokens=*" %%i in ('findstr /i /r /c:%1 "%~dpnx0"') do (
+        if exist "%%i" echo %%i
+      )
     
)
-    ::breaking, do not start fixme
     
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
+     ^| findstr /v /b /i /r /c:[a-z]:\\ /c::: "%~dpnx0"') do (
+      echo.%%i>>source.tmp
+    )
     move /y source.tmp "%~dpnx0"
   endlocal
 exit /b

History