program date2file;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var paramFileName: string;
    lNewFileName : string;
    lsYear, lsMonth, lsDay, lsHour, lsMinute: string;
    lYear, lMonth, lDay, lHour, lMinute, lSec, lMSec: word;
    Present: TDateTime;

begin
  paramFileName := 'Hello world!';
  paramFileName := ParamStr(1);
  // Bepaal filename
  lNewFileName := '';
  Present:= Now;
  DecodeDate(Present, lYear, lMonth, lDay);
  DecodeTime(Present, lHour, lMinute, lSec, lMSec);
  lsYear := IntToStr(lYear);
  lsMonth := IntToStr(lMonth); if length(lsMonth) < 2 then lsMonth := '0' + lsMonth;
  lsDay := IntToStr(lDay); if length(lsDay) < 2 then lsDay := '0' + lsDay;
  lsHour := IntToStr(lHour); if length(lsHour) < 2 then lsHour := '0' + lsHour;
  lsMinute := IntToStr(lMinute); if length(lsMinute) < 2 then lsMinute := '0' + lsMinute;

  // lNewFileName :=  lsYear + '_' + lsMonth +  '_' + lsDay + '_' + lsHour + '' + lsMinute;
  lNewFileName :=  lsYear + lsMonth + lsDay;

  // lNewFileName := 'sap' + lNewFileName + ExtractFileExt(paramFileName);
  lNewFileName := 'sap' + lNewFileName + '.log';  
  renameFile(paramFileName,lNewFileName);
  // Writeln(lNewFileName);
end.
