The following preprocessor code will generate a Pascal Scripting function that returns timestamp string for given relative file path:
#define SourcePath "C:\myappfiles"
function GetSourceFileDateTimeString(FileName: string): string;
begin
#define FileEntry(FileName, SourcePath) \
    Local[0] = GetFileDateTimeString(SourcePath, "yyyy/mm/dd hh:nn:ss", "-", ":"),\
    "  if SameText(FileName, '" + FileName + "') then " + \
        "Result := '" + Local[0] + "'" + NewLine + \
    "    else" + NewLine
#define ProcessFile(Root, Path, FindResult, FindHandle) \
    FindResult \
        ? \
            Local[0] = FindGetFileName(FindHandle), \
            Local[1] = (Len(Path) > 0 ? Path + "\" : "") + Local[0], \
            Local[2] = Root + "\" + Local[1], \
            (Local[0] != "." && Local[0] != ".." \
                ? (DirExists(Local[2]) \
                      ? ProcessFolder(Root, Local[1]) \
                      : FileEntry(Local[1], Local[2])) \
                : "") + \
            ProcessFile(Root, Path, FindNext(FindHandle), FindHandle) \
        : \
            ""
#define ProcessFolder(Root, Path) \
    Local[0] = FindFirst(Root + "\" + Path + "\*", faAnyFile), \
    ProcessFile(Root, Path, Local[0], Local[0])
    
#emit ProcessFolder(SourcePath, "")
  RaiseException(Format('Unexpected file "%s"', [FileName]));
end;
The generated script will be like:
function GetSourceFileDateTimeString(FileName: string): string;
begin
  if SameText(FileName, 'sub1\file1.exe') then Result := '2022-02-16 18:18:11'
    else
  if SameText(FileName, 'sub2\file2.exe') then Result := '2022-02-16 18:18:11'
    else
  if SameText(FileName, 'file3.exe') then Result := '2022-02-19 09:50:14'
    else
  if SameText(FileName, 'file4.exe') then Result := '2022-02-19 09:50:14'
    else
  RaiseException(Format('Unexpected file "%s"', [FileName]));
end;
(See Inno Setup: How do I see the output (translation) of the Inno Setup Preprocessor?)