1.

Solve : batch file data to email?

Answer»

I need a batch file which will search folders in this path
D:\users\alenkat\Users\Documents
D:\users\majag\Users\Documents
D:\users\toniz\Users\Documents
D:\users\juref\Users\Documents
D:\users\jakau\Users\Documents
D:\users\janezf\Users\Documents
D:\users\mihar\Users\Documents

and if there is no file
24.10.2014--datet.txt

it will send me an email with paths where that file doesn't EXIST

for sexample, here batch didn't find file 24.10.2014--datet.txt
D:\users\jakau\Users\Documents
D:\users\janezf\Users\Documents
D:\users\mihar\Users\Documents
and will send email with this in it

I list here just a fev folders I have it alot more
file 24.10.2014--datet.txt is changing every day so it should search for *.datet.txt







Batch has no native way to send email. You will EITHER have to use a third party utility to send the email or use vbscript.try this untested code:
Code: [Select]echo off
set "email="

if not exist D:\users\alenkat\Users\Documents\*datet.txt echo D:\users\alenkat\Users\Documents >>tmp.txt
if not exist D:\users\majag\Users\Documents\*datet.txt echo D:\users\majag\Users\Documents >>tmp.txt
if not exist D:\users\toniz\Users\Documents\*datet.txt echo D:\users\toniz\Users\Documents >>tmp.txt
if not exist D:\users\juref\Users\Documents\*datet.txt echo D:\users\juref\Users\Documents >>tmp.txt
if not exist D:\users\jakau\Users\Documents\*datet.txt echo D:\users\jakau\Users\Documents >>tmp.txt
if not exist D:\users\janezf\Users\Documents\*datet.txt echo D:\users\janezf\Users\Documents >>tmp.txt
if not exist D:\users\mihar\Users\Documents\*datet.txt echo D:\users\mihar\Users\Documents >>tmp.txt

:: Since batch does not support email, you will have to DOWNLOAD a 3rd party app to do it.
:: The paths are in the text file tmp.txtI have tested and works great bmail
http://retired.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm Quote from: Lemonilla on October 25, 2014, 01:51:53 PM

try this untested code:
Code: [Select]echo off
set "email="

if not exist D:\users\alenkat\Users\Documents\*datet.txt echo D:\users\alenkat\Users\Documents >>tmp.txt
if not exist D:\users\majag\Users\Documents\*datet.txt echo D:\users\majag\Users\Documents >>tmp.txt
if not exist D:\users\toniz\Users\Documents\*datet.txt echo D:\users\toniz\Users\Documents >>tmp.txt
if not exist D:\users\juref\Users\Documents\*datet.txt echo D:\users\juref\Users\Documents >>tmp.txt
if not exist D:\users\jakau\Users\Documents\*datet.txt echo D:\users\jakau\Users\Documents >>tmp.txt
if not exist D:\users\janezf\Users\Documents\*datet.txt echo D:\users\janezf\Users\Documents >>tmp.txt
if not exist D:\users\mihar\Users\Documents\*datet.txt echo D:\users\mihar\Users\Documents >>tmp.txt

:: Since batch does not support email, you will have to download a 3rd party app to do it.
:: The paths are in the text file tmp.txt

Thanks, I already MAKE this, but I can't add in batch 100 lines for 100 folders for every user and adding a NEW one everytime I add user to backup.

So batch need search folders and add result to one file which can be sended with bmailSo you want to check D:\users\*\users\documents then?  If so look at the command for /r.still have no clue how to put that search into one txt fileThis untested: 

Just a comment here that some social lubrication is nice in a forum, so you could add a thank you to the people that have replied
even if you only add "still have no clue how to put that search into one txt file".

Code: [Select]echo off
for /d %%a in ("d:\users\*") do (
   if not exist "%%a\Users\Documents\*--datet.txt" >>"file.log" echo Missing: "%%a\Users\Documents\*--datet.txt"
)
pause
thank you for helping.
After 3 hours of trying to make a batch I write that last post.
I really appreciate all help from all of you.

Your batch works perfect, like always. thank you again


Discussion

No Comment Found