I tried Robocopy
and a few others, but they only look at the date, but not time stamp of a file.
I found a few scripts that compare timestamps on files before copy, but not calling a .bat on time settings.
I have an executable that needs to be compressed and mailed to a usergroup, ONLY if it is newer than say 15 minutes. If older than 15 minutes, the script should just exit, and do nothing.
The Copy/RAR/MailTo function batch files are working, it is the time comparison that I need help with.
ADDED:
First bat file:
cd
cd c:\lighthouse\
mv production.exe production_old.exe /Y
cd\
cd c:\production\backup\
cd
xcopy "c:\production\backup\production.exe" "c:\lighthouse\production.exe" /Y
xcopy "c:\production\backup\production.exe" "i:\production.exe" /Y
xcopy "c:\production\backup\production.exe" "c:\RAR_and_Mail\production.exe" /Y
cd
Second bat file: This needs to ONLY run IF file production.exe is NEWER than 15 minutes, else EXIT.
cd\
cd c:\RAR_and_Mail\
xcopy "c:\RAR_and_Mail\*.rar" "c:\RAR_and_Mail\old\*.rar" /Y
del c:\RAR_and_Mail\*.rar
set MyDate=%date:/=.%.%
set WINRAR=C:\Program Files\WinRAR\rar.exe
set production=c:\RAR_and_mail\
cd /D %production%
"%WINRAR%" a -r -s -m5 /Y /R "%production%\%MyDate%_production.rar" "*.exe"
cd
call c:\batches\SendMail_Executable.bat
the third .bat being called:
echo off
set MyDate=%date:/=.%.%
c:\sendmail\sendEmail -o tls=no -f [email protected] -t [email protected] -s 254.20.10.100:25 -u "Latest work Update" -a "c:\RAR_and_Mail\%MyDate%_production.rar" -m "'Save As' the attachement, go to folder where it was saved, and 'extract here', overwriting existing production.exe."