Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for far.bat

(view source code of far.bat as plain text)

  1. @ECHO OFF
  2. IF [%3]==[] GOTO Syntax
  3.  
  4. VER | FIND "Windows NT" >NUL
  5. IF NOT ERRORLEVEL 1 GOTO NT
  6. VER | FIND "Windows 2000" >NUL
  7. IF NOT ERRORLEVEL 1 GOTO NT
  8.  
  9. %0.\
  10. CD %0.\..
  11. IF NOT EXIST far.kix GOTO Syntax
  12. KIX32 FAR.KIX $S=%1 $R=%2 $STRING=%3
  13. FOR %%A IN (CALL DEL) DO %%A %TEMP%.\_FAR_.BAT
  14. GOTO End
  15.  
  16. :NT
  17. IF NOT EXIST %~dpn0.kix GOTO Syntax
  18. KIX32 %~dpn0.kix $S=%1 $R=%2 $STRING=%3
  19. FOR %%A IN (CALL DEL) DO %%A %TEMP%.\_FAR_.BAT
  20. GOTO End
  21.  
  22. :Syntax
  23. ECHO FAR.BAT -- Find And Replace,  Version 1.00
  24. ECHO Search a string for a substring and replace it with another substring
  25. ECHO.
  26. ECHO FAR.BAT uses a Kix script named FAR.KIX which should be located in the
  27. ECHO same directory. Make sure KIX32.EXE can be found in the PATH.
  28. ECHO FAR.KIX creates a temporary batch file _FAR_.BAT in the TEMP directory.
  29. ECHO FAR.BAT uses the temporary batch file to store the modified string into
  30. ECHO an environment variable NEWSTRING.
  31. ECHO.
  32. ECHO Usage:  FAR  "string1"  "string2"  "string0"
  33. ECHO Where:  string0 = the string to be searched
  34. ECHO         string1 = the substring to search for
  35. ECHO         string2 = the substring that should replace string1
  36. ECHO All strings must be enclosed in double quotes.
  37. ECHO.
  38. ECHO Written by Rob van der Woude
  39. ECHO http://www.robvanderwoude.com
  40.  
  41. :End
  42.  

page last uploaded: 2017-08-21, 14:26