Find Newest (Log?) File in a Directory
Product Name: Find Newest (Log?) File in a Directory
Description : This scripts selects the file in a path that was updated/created today. This is ideal for selecting today's log file from an application, when you don't know the name of the log file (it's randomly created). The only things you do know is that it's daily and has a certain extension.
So now you can work with that log file going forward using another script.
You need to type in a full path and the filename using wildcards in
specific steps for this script to properly work. Use LINES 10 and 12 for
If there is no file or more than one file with today's update/creation date, an alarm is raised.
That last updated file and path will then become available in a global variables, the actual File Pattern you searched in that Directory is also available as a global variable. You can run this script from another procedure and then call out these variables in that procedure for further processing.
Line 10 has #global:SearchPath# : The Directory searched. For Example "C:\temp\".
Line 12 has #global:SearchFile#: The File Pattern Searched. This can you wildcards, just like you would use in the Command Box. For example "*.log".
Line 35 has #global:NewestFile#: Todays created/updated file as the result of the script.