Wacky_rubia

which

Dec 14th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. @echo off
  2. setlocal Enabledelayedexpansion
  3. if "%1" == "/?" echo it is which & goto :eof
  4.  
  5. if "%1" == "" (
  6. set /p file=write the file:
  7. ) else (
  8. set file=%1
  9. )
  10. set fdir=%cd%
  11. set p=%PATH%
  12. set p=%cd%;%p%
  13.  
  14. :start
  15.  
  16. for /f "delims=; tokens=1,*" %%i in ("%p%") do (
  17. set p=%%j
  18. set direc=%%i
  19. cd !direc!
  20.  
  21. if EXIST !file! (
  22. echo !direc!\!file!
  23. cd "!fdir!"
  24. goto :eof
  25. endlocal
  26. )
  27.  
  28.  
  29.  
  30. set e=%pathext%
  31.  
  32. :ex
  33. for /f "delims=; tokens=1,*" %%i in ("!e!") do (
  34. set e=%%j
  35. set exp=%%i
  36. )
  37. if EXIST !file!!exp! (
  38. echo !direc!\!file!!exp!
  39. cd "!fdir!"
  40. goto :eof
  41. endlocal
  42. ) else (
  43. if "!exp!" == ".MSC" (
  44. goto :start
  45. ) else (
  46. goto :ex
  47. endlocal
  48. )
  49. )
  50.  
  51. )
  52. rem if "!p!" == "" (
  53. echo none
  54. goto :eof
  55. endlocal
  56. rem )
Advertisement
Add Comment
Please, Sign In to add comment