Search code examples
ftpcmdunzip

Retrieve zip file from a predefined ftp link using bat or cmd file


I have a pre-defined ftp link with a zip file on the other end that I want to save to a directory on my cloud server (running Windows Server 2008). Once the zip file has been saved to a specified directory, lets say "c:\MyZipFiles\ZipFile-1.zip" for example, I want to unzip the file so that all files contained within the zip file are accessible within the same directory. I'm currently doing this manually and I want to automate this process by creating a .bat or .cmd file that will perform these steps for me.

Once the zip file is unzipped, I have a task in the Task Scheduler of Windows Server Manager ready to use the unzipped files for other things.

The pre-defined link looks something like this: ftp://idx.realtor.com/idx_download/files.zip

I would greatly appreciate anyone who can help me with this...


Solution

  • Batch file

    ftp -s:ftp_cmds.txt host-name-goes-here
    unzip local-file.zip
    exit
    

    ftp_cmds.txt

    username-goes-here
    password-goes-here
    cd remote-directory-goes-here
    get files.zip local-file-name-goes-here.zip
    quit
    

    This the batch file uses "unzip" to unzip the archive you can find it here: http://gnuwin32.sourceforge.net/packages/unzip.htm Either put the binaries in the same directory or put them somewhere else and set your windows PATH

    I used my own ftp to test most of this. Your ftp was offline for me, so it might take some tweaking but this should put you in the right direction.