Search code examples
cmddownloadftpdirectorysubdirectory

Download a file from ftp subdirectories using cmd script


I was trying to download multiple files from our ftp server using the script:

mget cd\dir_here\subdir_here\sample*.txt

but it didn't work so I tried to change to back slash:

mget cd/dir_here/subdir_here/sample*.txt

a message

Type set to A

appeared. What does that mean?


Solution

  • Type set to A

    This means that you've told the FTP server you will be transferring by ASCII.

    You almost never actually want to do ASCII, it is better to make a habit of using Binary for all transfers. (ASCII breaks the chain of custody, ASCII transfers can modify file contents such as changing New line characters and not sending correct Unicode characters and are completely unsuited to binary file contents, while the speed benefits are trivial.)

    You want to make sure your FTP script uses commands separately it looks like you put a CD along with an MGet here...?

    Example FTP Script:

    user USERNAME PASSWORD
    binary
    lcd C:\Local\File\System\Folder
    cd /root/dir_here/subdir_here
    mget sample*.txt
    quit
    

    This would be in a script file which would be specified in the FTP command when you call it from the command line or from a script.

    eg:

    ftp -n -i -v "-s:C:\Local\Path\To\FTP\Script.txt" SERVER_IP