Search code examples
ftpftp-clientbatch-file

Access properties of a file at FTP server


I want to access properties of a file named AH_store_20120117_00432.csv at ftp server with url ftp.mysite.com. Properties such as last modified date/time,size, etc.

I am accessing ftp server from batch file as follows:

@echo off
>ftp2.txt Echo open _ftp.mysite.com
>>ftp2.txt Echo username
>>ftp2.txt Echo password
>>ftp2.txt Echo cd dir1\dir2
>>ftp2.txt Echo quit
ftp -s:ftp2.txt

The file is present in dir2. FTP site can be accessed from above code, but not the file properties.

Kindly help. Thanks


Solution

  • command dir gets some info about files For your batch file:

    @echo off
    >ftp2.txt Echo open _ftp.mysite.com
    >>ftp2.txt Echo username
    >>ftp2.txt Echo password
    >>ftp2.txt Echo cd dir1\dir2
    >>ftp2.txt Echo dir
    >>ftp2.txt Echo quit
    ftp -s:ftp2.txt
    

    You will get a list of the records included date of file. Format of the records may vary widely from system to system (RFC 959 - File Transfer Protocol). For example Windows FTP server may response:

    12-04-11  08:00PM               209665 04a64ad1-33c6-48ec-9931-abcc6445c491
    ...
    

    Linux may response:

    -rwxrwxrwx   1 owner    group             156 Jan 27  2010 warning.log
    ...