/* FileDate, Version 3.11 */ /* Cloned from the Norton Utilities for DOS */ /* Change date and time attributes of specified files */ /* Written by Rob van der Woude */ /* http://www.robvanderwoude.com */ /* Initialize RexxUtil */ If RxFuncQuery( "sysloadfuncs" ) <> 0 Then Do Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs" Call sysloadfuncs End /* Defaults */ filespec = "*.*" dateattr = "" timeattr = "" newdate = "" newtime = "" /* Command line parsing */ Parse Upper Arg parameters par. = "" par.0 = 0 Do i = 1 By 1 Until parameters = "" Parse Value parameters With par.i parameters par.0 = par.0 + 1 End If par.0 > 1 Then Do i = 1 To par.0 Select When Left( par.i, 2 ) = "/D" Then dateattr = SubStr( par.i, 3 ) When Left( par.i, 2 ) = "/T" Then timeattr = SubStr( par.i, 3 ) Otherwise filespec = par.i End End Else Do Call Syntax End /* Either a new date or a new time or both should be specified */ If dateattr||timeattr = "" Then Call Syntax If dateattr <> "" Then Do If Length( dateattr ) < 6 Then Call Syntax If Pos( "-", dateattr ) > 0 Then Parse Value dateattr With dd"-"mm"-"yy If Pos( "/", dateattr ) > 0 Then Parse Value dateattr With dd"/"mm"/"yy If DataType( yy, "W" ) = 0 Then Call Syntax If DataType( mm, "W" ) = 0 Then Call Syntax If DataType( dd, "W" ) = 0 Then Call Syntax If yy < 100 Then yy = 2000 + yy If mm < 10 Then mm = Right( mm, 2, "0" ) If dd < 10 Then dd = Right( dd, 2, "0" ) newdate = yy||"-"||mm||"-"||dd End If timeattr <> "" Then Do If Pos( ":", timeattr ) = 0 Then Call Syntax If Length( timeattr ) < 4 Then Call Syntax Parse Value timeattr With hh":"mn":"ss Select When Pos( "A", mn ) = 0 Then nop When Pos( "A", mn ) = 3 Then mm = left( mm, 2 ) When Pos( "P", mn ) = 0 Then nop When Pos( "P", mn ) = 3 Then Do mm = left( mm, 2 ) hh = hh + 12 End Otherwise Call Syntax End If ss = "" Then ss = 0 If DataType( hh, "W" ) = 0 Then Call Syntax If DataType( mn, "W" ) = 0 Then Call Syntax If DataType( ss, "W" ) = 0 Then Call Syntax If hh < 10 Then hh = Right( hh, 2, "0" ) If mn < 10 Then mn = Right( mn, 2, "0" ) If ss < 10 Then ss = Right( ss, 2, "0" ) newtime = hh||":"||mn||":"||ss End Call SysFileTree filespec, "file.", "FO" If file.0 = 0 Then Do Say "0D0A"X||"Invalid filespec or file not found"||"0D0A"X Call Syntax End Else Do i = 1 to file.0 /* Retrieve old values for file date and time */ Parse Value SysGetFileDateTime( file.i, "M" ) With olddate oldtime /* Set new values to old ones if not specified */ If newdate = "" Then newdate = olddate If newtime = "" Then newtime = oldtime /* Set new values */ Call SysSetFileDateTime file.i, newdate, newtime End /* Normal program termination */ Exit 0 Syntax: Say Say "FileDate, Version 3.11 for Regina Rexx with RexxUtil" Say "Inspired by the Norton Utilities for DOS" Say "Change date and time attributes of specified files" Say Say "Usage: FILEDATE.REX [ filespec ] /Ddd/mm/yy /Thh:mm:ss" Say Say 'Where: "filespec" is the specification of the file(s) to be' Say ' changed; wildcards allowed; default "*.*"' Say ' "dd/mm/yy" is the new file date to be set' Say ' "hh:mm:ss" is the new file time to be set' Say Say Say "You may specify only a new file date or time, or both; the" Say "options not specified will not be changed." Say "The year may be specified in either 2 or 4 digits; if 2 digits" Say "are used, 2000 is added to the specified year." Say Say "Written by Rob van der Woude" Say "http://www.robvanderwoude.com" Exit 1 Return