Need to setup scheduled batch file to FTP a file to network directory

Posted on 2008-11-11
Last Modified: 2013-12-09

I have a DOS based machine that measures the weight of a product, stores it in memory and then writes data to a text file every 2 hours. I want to setup a scheduled batch file that copies this text file via FTP to a location on a network dive and automatically adds a date stamp to the end of the file.

The location of the text file is: ftp://10.X.X.X/STATEX/statex.txt

Example of where I would like the file FTPed/copied: //server/share/statex.txt

Can the file be date stamped similar to this syntax: /statex12-11-2008.txt?

I would like to run this batch file every 12-24 you recommend I just setup a simple scheduled task to run from the domain controller?

Thanks ALOT for your help!
Question by:rubydesi
    LVL 40

    Accepted Solution

    to set filename with date

    set file=fb%date:~10,4%%date:~4,2%%date:~7,2%

    to automatically ftp, have an ftp file ( e.g. ftp.txt) like

    lcd c:\ftpdir
    cd /remotedir
    mput fb*

    have a .bat file that contains

    ftp -s:ftp.txt server_ip

    then use the task scheduler to shedule it

    Author Comment


    Thanks for the reply.

    Whats the exact syntax for setting the filename with the date including the filename?

    You have: set file=fb%date:~10,4%%date:~4,2%%date:~7,2% - where does statex.txt fit into this string?
    LVL 40

    Expert Comment

    what I gave was an example and you need to customize:

    set file=statex%date:~10,4%%date:~4,2%%date:~7,2%.txt
    rename statex.txt %file%


    Author Comment

    OK, my ftp.txt file is

    lcd \\server\share\Statex
    cd statex
    get statex.txt

    This has copied the file from the DOS machine to the network share.

    Where in the process can I use the "set file" batch command? I only need the network share copy of the file date stamped, so can I tack that onto the end of the batch file AFTER ftp.txt has finished? Or should I create a second batch file that runs after the first one finishes?

    Thanks again.

    Author Comment

    Nevermind on previous question, it is all working successfully now.
    LVL 40

    Expert Comment

    I was a way from my computer, any help needed?

    Author Comment

    Nope, working 100%, thanks again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Have you ever stumbled upon a software that is so great that you just love? It happened to me. Love at first sight. Filezilla Server.   Ok its not the most advanced ftp server I've came across. But its a fairly simple piece of software to get the …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now