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

Author Topic: Batch file to find newly updated file in FTP Server  (Read 8170 times)

0 Members and 1 Guest are viewing this topic.

paulwintech

    Topic Starter


    Greenhorn

    Batch file to find newly updated file in FTP Server
    « on: August 12, 2010, 12:41:55 AM »
    HI,

    Everyday we need to download newly added files are folder from FTP server to our local machine. I have already downloaded the folder from FTP server. But i need the following in batch script

    1. Daily it need to search for any new files are folder added, If so it has to be downloaded to my local machine.

    2. It should search all the subfolder too, for example i have folder called A and it may contain subfolders like xyz and even in that we may have some updated files.

    3. Is there any possible to use GMail SMTP settings and send a mail using batch script. If we find any new files that details has to be mailed to the particular users to download.


    Please help me on this issue! I used Google and found nothing...

    Thanks
    Paulwintech

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Batch file to find newly updated file in FTP Server
    « Reply #1 on: August 12, 2010, 01:17:24 PM »
    More questions than answers I'm afraid.

    Quote
    1. Daily it need to search for any new files are folder added, If so it has to be downloaded to my local machine.

    How do you recognize a new file or folder? Date? Time?

    What happens to files or folder that are downloaded? Do they get deleted from the server, moved elsewhere on the server?

    Quote
    3. Is there any possible to use GMail SMTP settings and send a mail using batch script. If we find any new files that details has to be mailed to the particular users to download.

    If you have a GMAIL account you can use the Google SMTP server. Click here. You will probably need to write a Windows script using the CDO.Message object.

    For batch scripts, you can use Blat which requires a download.

    You can also use your own mail server if you have one or your ISP server.

    How is all this being done now? Once you can do a walk through of the procedure you're currently using, automating it should be relatively easy.

    Let us know.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    paulwintech

      Topic Starter


      Greenhorn

      Re: Batch file to find newly updated file in FTP Server
      « Reply #2 on: August 17, 2010, 05:03:01 AM »
      Hi,

        I need to find new files using date/time

      Regards
      Paulwintech

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Batch file to find newly updated file in FTP Server
      « Reply #3 on: August 17, 2010, 07:51:18 AM »
      This little piece of code will filter the current files (including files in subfolders). It uses the current date for comparison:

      Code: [Select]
      @echo off
      setlocal enabledelayedexpansion

      set dt=%date:~4,10%
      for /f "tokens=* delims=" %%i in ('dir c:\folder /a-d /s /b') do (
        set fdt=%%~ti
        set fdt=!fdt:~0,10!
        if !fdt! EQU %dt% echo !fdt! %%i


      Now that you can isolate them, what happens next? Stage them in a transmission folder? Transmit each file separately?

      Note: My system date is in the format of dow mm/dd/yyyy. The set dt= statement in the file isolates the mm/dd/yyyy portion. You may have to tweak it for your local date format.

      Let us know.  8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      ghostdog74



        Specialist

        Thanked: 27
        Re: Batch file to find newly updated file in FTP Server
        « Reply #4 on: August 17, 2010, 08:11:56 AM »
        @sidewinder, That will only work on his local machine. He needs a way to find the latest files at remote.

        @OP, This is a job for a programming language with the necessary ftp , smtp libraries, not batch. ( not saying it can't be done, but its tedious ). I recommend Python (or Perl).

        paulwintech

          Topic Starter


          Greenhorn

          Re: Batch file to find newly updated file in FTP Server
          « Reply #5 on: August 23, 2010, 11:31:13 PM »
          Hi,

            Is there any possible to take the updated files from share and save it in backup server, For example in Machine A and Machine B have share called mybackup. Everyday they put some of their required backup in that folder.  Backup server should take or compare for any new files present in the share of A/B, and copy the same into backup server.

             Please let me know is there any possibility to do so.

          Thanks
          Paulwintech