Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for locase3.bat

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

  1. @ECHO OFF
  2. :: Check Windows version -- NT 4 or later required
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Use local variables
  6. SETLOCAL
  7.  
  8. :: Check command line arguments
  9. IF "%~1"=="" GOTO Syntax
  10. ECHO %* | FIND "/?" >NUL && GOTO Syntax
  11. SET OK=1
  12. :: FOR %%A IN (%*) DO IF NOT EXIST %%A IF /I NOT "%%~A"=="/S" SET OK=0
  13. FOR %%A IN (%*) DO IF NOT EXIST %%A SET OK=0
  14. IF "%OK%"=="0" GOTO Syntax
  15.  
  16. :: The actual command by Niels Stout uses DIR's
  17. :: /L switch to convert filenames to lower case
  18. FOR /F "tokens=* delims=" %%A IN ('DIR %* /B /L') DO REN "%%~A" "%%~A"
  19. GOTO End
  20.  
  21. :Syntax
  22. ECHO.
  23. ECHO LoCase.bat,  Version 3.00 for Windows NT 4 and later
  24. ECHO Use DIR /L to rename specified file(s) to all lowercase
  25. ECHO.
  26. ECHO Usage:  LOCASE  filespec  [ filespec  [ ... ] ]
  27. ECHO Where:          filespec  designates a file or group of files in
  28. ECHO                           the current directory to be renamed
  29. ECHO.
  30. ECHO DIR /L trick by Niels Stout
  31. ECHO Written by Rob van der Woude
  32. ECHO http://www.robvanderwoude.com
  33.  
  34. :End
  35. IF "%OS%"=="Windows_NT" ENDLOCAL
  36.  

page last modified: 2024-04-16; loaded in 0.0071 seconds