I need to find the latest created file in a FTP folder. However the FTP server is not returning full timestamps for files with the LIST command (missing the year):
drwxr-xr-x 2 owner group 0 Nov 9 17:29 archive
drwxr-xr-x 2 owner group 0 Nov 9 17:35 category
drwxr-xr-x 2 owner group 0 Jan 9 07:21 images
And the MLSD command is not supported.
So currently I check the timestamp of each file with the MDTM command. Is there a more efficient way?
I am using the ftplib wrapper.
Best Answer
man ftp says:
So, most UNIX systems will produce output from the command ‘ls -l’ and such command either shows date or date and time, depending on the “age” of file:
Taking into account you are after the FTP command to get the timestamps reliably and efficiently, I'm affraid your approach (MDTM command) is the only one not including programming stuff.