Category : Batch File Utilities - mostly for DOS
Archive   : DATSTAMP.ZIP
Filename : DATSTAMP.PAS

 
Output of file : DATSTAMP.PAS contained in archive : DATSTAMP.ZIP
program FileDate;
uses Dos;
const
Attr : word = $20;
I : word = 1;
K : byte = 1;
None : boolean = false;
Max : boolean = false;
SeqNum : string[2] = '';
var
DateStrFileName : string[12];
DateStrPathName : string[79];
FullPathName : string[79];
DirNStr : DirStr;
FileNStr : NameStr;
ExtNStr : ExtStr;
FileNumber : string[2];
WorkFName : file;
FileAttr : word;
FindRec : SearchRec;
function DateNib(InDate : word) : string;
const
Zero : string[1] = '0';
InStr : string[2] = '';
begin
if InDate > 99 then InDate := InDate -1900;
if InDate = 0 then begin WriteLn('Date Error (0).'); Halt; end;
Str(InDate,InStr);
if Ord(InStr[0]) < 2 then
DateNib := Zero + InStr
else
DateNib := InStr;
end;
function fDateStr : string;
var
Year, Month, Day, DayOfWeek : Word;
YearStr, MonthStr, DayStr : String[2];
begin
GetDate(Year, Month, Day, DayofWeek);
YearStr := DateNib(Year);
MonthStr := DateNib(Month);
DayStr := DateNib(Day);
fDateStr := MonthStr + DayStr + YearStr;
end;
begin
if ParamCount < 1 then
begin
WriteLn('Syntax: DATSTAMP [filename.ext]');
WRiteLn('Result: mmddyy#n.ext');
Halt;
end;
FullPathName := ParamStr(1);
FindFirst(FullPathName, Attr, FindRec);
case DOSerror of
0: None := false;
2: Begin WriteLn('File not found.'); Halt; end;
3: Begin WriteLn('Path not found.'); Halt; end;
18: Begin WriteLn('No more files.'); Halt; end;
else
WriteLn('Other error finding file.')
end;
repeat
Str(K, FileNumber);
SeqNum := '#' + FileNumber;
FSplit(FullPathName, DirNStr, FileNStr, ExtNStr);
DateStrFileName := fDateStr + SeqNum + ExtNStr;
DateStrPathName := DirNStr + DateStrFileName;
FindFirst(DateStrPathName, Attr, FindRec);
case DOSerror of
0 : None := false;
2 : None := true;
18 : None := true;
else
begin WriteLn('File error.'); Halt; end;
end;
if K = 9 then Max := true;
if Max and not None then begin
WriteLn('Error. No room.'); Halt;
end;
K := Succ(K);
until None or Max;
Assign(WorkFName, FullPathName);
Rename(WorkFName, DateStrPathName);
case IOresult of
0 : begin WriteLn('Filename.EXT set to ', DateStrFileName); Exit; end;
else
Halt;
end;
end.


  3 Responses to “Category : Batch File Utilities - mostly for DOS
Archive   : DATSTAMP.ZIP
Filename : DATSTAMP.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/