I have a log files populating on a windows box in the BES directory. I want to find a line in the latest log file. The name of the log file is somewhat random.
This is what I have so far:
code
if (exists find files "
.log" of folder (location of client)) then following texts of firsts “Elapsed Time:” of lines whose (it starts with “Elapsed Time:”) of (find files "
.log" of folder (location of client)) else “”
[/code]
I have no idea how to specify that the log file needs to be the latest one.
Maybe use the “maximum modification time of file” to find the latest log file before searching for our desired text.
Here are some examples.
q: maximum of modification times of files whose (name of it ends with ".log") of folder "c:\temp"
q: following texts of firsts "Elapsed Time:" of lines whose (it starts with "Elapsed Time:") of files whose (modification time of it = maximum of modification times of files whose (name of it ends with ".log") of folder "c:\temp") of folder "c:\temp"
I have an application that writes a log file to each user folder, but I need to be able to find the latest log file from all user folders to figure out when the last time this program ran was. This is an expansion of this problem. Here is my code to find the latest log file:
file whose (name of it ends with “.log” AND creation time of it = (maximum of creation times of files whose (name of it ends with “.log”) of folders “AppData\Local\theProgramsFolder\logs” of folders whose (exists folder “AppData\Local\theProgramsFolder\logs” of it) of folder “C:\Users”)) of folders “AppData\Local\theProgramsFolder\logs” of folders whose (exists folder “AppData\Local\theProgramsFolder\logs” of it) of folder “C:\Users”