Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to create a batch file to check a folder for all the .ftp files. If I don't see a .ftp file within the past two days I need to send out an email.

Hmm....Tricky
Try This:==FtpFinder.bat==
@ECHO OFF
SET cDate=%DATE:~7,2%
:Start
IF NOT EXIST EndDate.txt GOTO MakeFile
FOR /F "tokens=*" %%D IN (EndDate.txt) DO SET eDate=%%D
IF %cDate% GEQ %eDate% GOTO Email
FOR %%F IN (*.ftp) DO ECHO %%F>FtpFiles.txt
GOTO End
:MakeFile
SET /A eDate=cdate+2
ECHO eDate>EndDate.txt
GOTO Start
IF NOT EXIST FtpFiles.txt START mailto:YourEmail@YourDomain.com?subject=FTP%%20Files^&body=No%%20.FPT%%20Files%%20Found
:End
----------------
<::Note::>
Since DOS doesnt include a way to send e-mails, you'll still have to click the "Send" button on your "Send Message" screen if no .FTP files were found within 2 days"If it jams, force it. If it breaks, it needed replacing anyway."
-Murphy's Laws

Nothing much to do with DOS, but there ARE command line mailers.
As to the "date math" mess, I'll just read along for now.
If at first you don't succeed, you're about average.M2

Yes, If you aren't able to come to your computer every two days to click send, a third-party e-mail sender is just what you need.
Also, if your going to run this program day after day, you should probably add the lines:
IF EXIST FtpFiles.txt DEL FtpFiles.txt
DEL EndDate.txt
After the line:
IF NOT EXIST FtpFiles.txt START mailto:YourEmail@YourDomain.com?subject=FTP%%20Files^&body=No%%20.FPT%%20Files%%20Found
"If it jams, force it. If it breaks, it needed replacing anyway."
-Murphy's Laws

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |