Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for locase.cmd

(view source code of locase.cmd as plain text)

  1. /* Rename file(s) to all lower case */
  2. /* Written by Rob van der Woude     */
  3. /* http://www.robvanderwoude.com    */
  4.  
  5. /* Parse command line parameters */
  6. lfn = ""
  7. parse upper arg '"'filespec'"' dummy"/"option
  8. if filespec = "" then do
  9. 	parse upper arg filespec dummy"/"option
  10. end
  11. else do
  12. 	/* Long file name detected */
  13. 	lfn = '"'
  14. end
  15. if dummy   <> "" then call Syntax
  16. if filespec = "" then call Syntax
  17. if option <> "" then do
  18. 	option = left( option, 1 )
  19. 	if option <> "S" then call Syntax
  20. end
  21.  
  22. /* Initialize RexxUtil */
  23. if RxFuncQuery( SysLoadFuncs ) = 1 then do
  24. 	call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  25. 	call SysLoadFuncs
  26. end
  27.  
  28. call SysFileTree filespec, "file.", "FO"||option
  29. if file.0 = 0 then call Syntax "FileNotFound"
  30. do i = 1 to file.0
  31. 	newname = translate( filespec( "N", file.i ), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" )
  32. 	say "1B"X||"[1;1H"||"1B"X||"[K"||newname||"0D0A"X||"1B"X||"[K"||"1B"X||"[1A"
  33. 	address CMD "@CMD /C REN "||lfn||file.i||lfn||" "||lfn||newname||lfn
  34. end
  35. EXIT
  36.  
  37.  
  38. Syntax: procedure expose filespec
  39. 	say
  40. 	if arg( 1 ) = "FileNotFound" then do
  41. 		say "File not found: "||filespec
  42. 	end
  43. 	else do
  44. 		say "LoCase - convert file names to all lower case"
  45. 		say "Written by Rob van der Woude"
  46. 		say "http://www.robvanderwoude.com"
  47. 	end
  48. 	say
  49. 	say "Usage:  LOCASE  <filespec>  [ /Subdirectories ]"
  50. 	exit
  51. return
  52.  

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