Download Selectfile

 

 

What does it do?

Selectfile allows you to select the oldest and/or the newest file in a directory using batch files. I use batch scripts very often, and sometimes it comes in handy to be able to point to the newest file created in a specific folder. For instance, when using NTBackup, there is always a backup1-10.log file written on the server, but there is no way to email this to the administrator.

 

Usage

selectfile d:\backuplogs\*.log

-> searches in the folder for all .log files. You must use a file flag for the search query, else the program will fail.

 

Selectfile then creates environment variables to give back the oldest and newest file.

 

Because of compiler limitations the environment variables must be set in the current CMD session, that's why selectfile creates a batch file in the current folder called _selectfile.bat. This file must be executed immediatly after selectfile.exe was executed to set the environment variables. Hope I will resolve this extra step in the future. For now it just works.

 

Example batch

@echo off

selectfile d:\backuplogs\*.log

call _selectfile.bat

echo Newest file: %SF_NEWEST%

echo Oldest file: %SF_OLDEST%

?cmdsmtp? d:\backuplogs\%sf_newest% -to:anyone@any.where

echo.

REM Cleaning up

SET SF_NEWEST=

SET FS_OLDEST=

REM end of batch file.

 

Tips

Check out www.blat.net for a nice commandline smtp client. It does great jobs for me.

 

Questions, Suggestions?

Send an email to software@anykeyonline.nl for any questions or suggestions or just to say what you think about this little utility. Please note that you must put ANYKEY-SOFTWARE in the subject, or else the email will not be accepted by the mail server, this is for preventing spam in my mailbox.

 

Licensing

It's free for any home, educational or business use. As long as you don't harm anyone or anything with it. Also read the disclaimer for more information.

 

Disclaimer

This utility is distributed "as is" and without warranties as to performance, accuracy, or any other warranties whether expressed or implied. The author is not responsible for any costs or damages incurred, whether incidental or consequential, by the use or misuse of this utility.