1. #1
    jcgriff2's Avatar
    Join Date
    Feb 2012
    New Jersey Shore
    • specs System Specs
      • Manufacturer:
      • Model Number:
        HP ENVY TouchSmart 17-j130us Notebook - E8A04UA
      • Motherboard:
        HP Insyde 720265-501 6050A2549501-MB-A02
      • CPU:
        Intel Core i7-4700MQ Processor with Turbo Boost up to 3.4GHz.
      • Memory:
        12GB DDR3L SDRAM (2 DIMM)
      • Graphics:
        Intel HD graphics 4600 with up to 1792MB total graphics memory
      • Sound Card:
        Beats Audio quad speakers and two subwoofers
      • Hard Drives:
        1TB 5400RPM hard drive with HP ProtectSmart Hard Drive Protection
      • Disk Drives:
        Hitachi 500 GB SSD; 7 TB USB External
      • Power Supply:
      • Case:
      • Display:
        17.3-inch diagonal HD+ BrightView LED-backlit touchscreen display (1600 x 900)
      • Operating System:
        Windows 8.1

    Batch Script to Upload a File to Your Server via FTP


    The following batch script uploads a file to a client server via FTP.

    Open up a Notepad; copy/paste the following into it:

    @echo off
    :: Obtain today's date in format YYYYMMDD
    set x1=%date:~10,4%
    set x2=%date:~4,2%
    set x3=%date:~7,2%
    :: The CSV file is presumed to be in your Documents directory 
    set userdir=%userprofile%\documents
    :: Build CSV file path + filename
    set x=%userdir%\%x1%%x2%%x3%.csv
    :: Echo the FTP commands to a text file - done so that ENV variables carry through
    echo open  ftp.sysnative.com>%windir%\system32\ftpcmdtemp.txt
    echo Server User Name>>%windir%\system32\ftpcmdtemp.txt
    echo Server Password>>%windir%\system32\ftpcmdtemp.txt
    echo binary>>%windir%\system32\ftpcmdtemp.txt
    echo cd Enter server directory path - including "public_html" if Linux>>%windir%\system32\ftpcmdtemp.txt
    echo put %x%>>%windir%\system32\ftpcmdtemp.txt
    echo quit>>%windir%\system32\ftpcmdtemp.txt
    :: FTP Execution Commands
    ftp -s:%windir%\system32\ftpcmdtemp.txt %x%
    Save it in \windows\system32; filename = FTPup.bat

    Change the items in RED to your personal info.

    To execute the newly saved FTPup.bat - enter the batch name into an ADMIN CMD prompt screen or go into Windows Explorer, RIGHT-click on FTPup.bat; select "Run as Administrator"

    This particular batch script was written for an OP at TSF Forums.

    For more information like the input file's name, please see my TSF post - batch script to upload csv to website mysql - Tech Support Forum

    Any questions, modifications or other assistance, please post in this thread and I will try my best to answer them.

    Regards. . .


    EDIT: Make sure the password has no special chars in it - batch thinks they are something else. Letters + numbers only.

    For example - if you have an ampersand (&) in the password, a batch script sees it and expects a new command to follow. Many of the symbols above the number keys have a special meaning in batch.
    Last edited by jcgriff2; 08-08-2017 at 03:17 PM.

    • Ad Bot



Similar Threads

  1. [PHP] Upload Script
    By Will Watts in forum Programming
    Replies: 4
    Last Post: 07-12-2013, 03:54 PM
  2. A Simple Batch Script Explained
    By jcgriff2 in forum Programming
    Replies: 5
    Last Post: 03-18-2013, 07:08 AM
  3. Pass Generator Batch script - Created by Ace
    By AceInfinity in forum Programming
    Replies: 0
    Last Post: 10-01-2012, 01:24 AM
  4. WMI batch script to obtain literal and numeric day of week
    By jcgriff2 in forum Windows Tips & Tricks
    Replies: 1
    Last Post: 07-10-2012, 11:28 PM

Log in

Log in