Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file data to email  (Read 3737 times)

0 Members and 1 Guest are viewing this topic.

Blisk

    Topic Starter


    Intermediate

    Thanked: 1
    • Experience: Familiar
    • OS: Windows 7
    batch file data to email
    « on: October 25, 2014, 11:07:39 AM »
    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








    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: batch file data to email
    « Reply #1 on: October 25, 2014, 12:51:44 PM »
    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.

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: batch file data to email
    « Reply #2 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
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    Blisk

      Topic Starter


      Intermediate

      Thanked: 1
      • Experience: Familiar
      • OS: Windows 7
      Re: batch file data to email
      « Reply #3 on: October 25, 2014, 02:58:37 PM »

      Blisk

        Topic Starter


        Intermediate

        Thanked: 1
        • Experience: Familiar
        • OS: Windows 7
        Re: batch file data to email
        « Reply #4 on: October 25, 2014, 03:00:54 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 bmail

        Lemonilla



          Apprentice

        • "Too sweet"
        • Thanked: 70
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: batch file data to email
        « Reply #5 on: October 25, 2014, 03:36:48 PM »
        So you want to check D:\users\*\users\documents then?  If so look at the command for /r.
        Quote from: patio
        God Bless the DOS Helpers...
        Quote
        If it compiles, send the files.

        Blisk

          Topic Starter


          Intermediate

          Thanked: 1
          • Experience: Familiar
          • OS: Windows 7
          Re: batch file data to email
          « Reply #6 on: October 26, 2014, 01:14:31 AM »
          still have no clue how to put that search into one txt file

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: batch file data to email
          « Reply #7 on: October 26, 2014, 02:36:33 AM »
          This 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

          Blisk

            Topic Starter


            Intermediate

            Thanked: 1
            • Experience: Familiar
            • OS: Windows 7
            Re: batch file data to email
            « Reply #8 on: October 26, 2014, 03:22:59 AM »
            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 :)