Findnewesti

Find Newest (Log?) File in a Directory

What is the name of the newest file?

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.

Developer
  • Name: Onno de Vries
  • Company: Kaseya
  • Website: http://www.kaseya.com
  • Contact Developer
  • Summary
  • Find Newest (Log?) File in a Directory
  • 15 Downloads
  • Released on August 26th, 2016
  • Reviews

    Find Newest (Log?) File in a Directory has no reviews.

    Discussion
    Gravatar for Buster Davis
    Buster Davis about 2 years ago

    Does this script look only at the parent directory or would it look at subdirectories in the parent directories

    Gravatar for Onno de Vries
    Onno de Vries about 2 years ago

    Hi Buster Davis, this script in it's current state, would only work on the parent directory and not it's subdirectories.

    Changing it to have it look through subdirectories as well is easy actually:
    1. Open the Agent Procedure for editing
    2. Click on line 15, this currently says "dir #global:SearchPath##global:SearchFile# /a-d /o-d /tw|findstr /C:"%date:~-10%">>#awd#\NewestFile\FileList.txt"
    3. change that line to say "dir #global:SearchPath##global:SearchFile# /s /a-d /o-d /tw|findstr /C:"%date:~-10%">>#awd#\NewestFile\FileList.txt"
    4. Save the Agent Procendure and Run that on a test machine that you know has that file type in at least one subdirectory of the chosen search path.

    Let me now how you're getting along with that!?

    J
    Onno