Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for filedate.cmd

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

  1. /* FileDate,  Version 2.00                            */
  2. /* Cloned from the Norton Utilities for DOS           */
  3. /* Change date and time attributes of specified files */
  4. /* Copyrights (C) 1999, Rob van der Woude             */
  5.  
  6. /* Initialize RexxUtil */
  7. if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
  8. 	call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  9. 	call SysLoadFuncs
  10. end
  11.  
  12. /* Initialize  Quercus System's RexxLib */
  13. if RxFuncQuery( "RexxLibRegister" ) <> 0 then do
  14. 	call RxFuncAdd "RexxLibRegister", "rexxlib", "RexxLibRegister"
  15. 	call RexxLibRegister
  16. end
  17.  
  18. /* Defaults */
  19. dateattr = ""
  20. timeattr = ""
  21. newdate  = ""
  22. newtime  = ""
  23.  
  24. /* Command line parsing */
  25. parse upper arg parameters
  26. par.  = ""
  27. par.0 = 0
  28. do i = 1 by 1 until parameters = ""
  29. 	parse value parameters with par.i parameters
  30. 	par.0 = par.0 + 1
  31. end
  32. if par.0 > 1 then do i = 1 to par.0
  33. 	select
  34. 		when left( par.i, 2 ) = "/D" then dateattr = substr( par.i, 3 )
  35. 		when left( par.i, 2 ) = "/T" then timeattr = substr( par.i, 3 )
  36. 		otherwise filespec = par.i
  37. 	end
  38. end
  39. else do
  40. 	call Syntax
  41. end
  42.  
  43. if dateattr <> "" then do
  44. 	if length( dateattr )   < 6 then call Syntax
  45. 	if pos( "-", dateattr ) > 0 then parse value dateattr with dd"-"mm"-"yy
  46. 	if pos( "/", dateattr ) > 0 then parse value dateattr with dd"/"mm"/"yy
  47. 	if datatype( yy, "W" ) = 0 then call Syntax
  48. 	if datatype( mm, "W" ) = 0 then call Syntax
  49. 	if datatype( dd, "W" ) = 0 then call Syntax
  50. 	newdate = 19000000 + ( 10000 * yy ) + ( 100 * mm ) + dd
  51. 	if newdate < 19800000 then newdate = newdate + 1000000
  52. end
  53.  
  54. if timeattr <> "" then do
  55. 	if pos( ":", timeattr ) = 0 then call Syntax
  56. 	if length( timeattr )  <  4 then call Syntax
  57. 	parse value timeattr with hh":"mn":"ss
  58. 	select
  59. 		when pos( "A", mn ) = 0 then nop
  60. 		when pos( "A", mn ) = 3 then mm = left( mm, 2 )
  61. 		when pos( "P", mn ) = 0 then nop
  62. 		when pos( "P", mn ) = 3 then do
  63. 			mm = left( mm, 2 )
  64. 			hh = hh + 12
  65. 		end
  66. 		otherwise call Syntax
  67. 	end
  68. 	if ss = "" then ss = 0
  69. 	if datatype( hh, "W" ) = 0 then call Syntax
  70. 	if datatype( mn, "W" ) = 0 then call Syntax
  71. 	if datatype( ss, "W" ) = 0 then call Syntax
  72. 	newtime = ( 10000 * hh ) + ( 100 * mn ) + ss
  73. 	newtime = right( newtime, 6, "0" )
  74. end
  75.  
  76. call SysFileTree filespec, "file.", "FO"
  77. if exist.0 = 0 then do
  78. 	say "Invalid filespec or file not found"||"0D0A"X
  79. 	call Syntax
  80. end
  81. else do i = 1 to file.0
  82. 	interpret "call dosfdate '"||file.i||"', "||newdate||", "||newtime
  83. end
  84. EXIT
  85.  
  86. Syntax:
  87. 	say "FileDate,  Version 2.00"
  88. 	say "Cloned from the Norton Utilities for DOS"
  89. 	say "Change date and time attributes of specified files"
  90. 	say "Copyrights (C) 1999, Rob van der Woude"
  91. 	say
  92. 	say "Usage:  FILEDATE  filespec  /Ddd/mm/yy  /Thh:mm:ss"
  93. 	exit 255
  94. return
  95.  

page last modified: 2024-02-26; loaded in 0.0185 seconds