Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Created Date of file via ftp

Good Day!

How to get created date of a file via ftp?. Im using web2py,python,ftplib and filezilla as a ftp server. I can get the modified date via f.sendcmd('MDTM '+filename).

Any suggestions? Thanks!

like image 878
user3005006 Avatar asked Oct 28 '25 10:10

user3005006


1 Answers

You have something like the following:

connection = ftplib.FTP(**ftpCredentials)
modifiedTime = connection.sendcmd('MDTM ' + fileName)
# successful response: '213 20120222090254'

To interpret the modified time, you should do the following:

from datetime import datetime

print datetime.strptime(modifiedTime[4:], "%Y%m%d%H%M%S").strftime("%d %B %Y %H:%M:%S")
# prints something like 01 January 1970 09:30:01

Source: this blog post @ http://alexharvey.eu/code/python/get-a-files-last-modified-datetime-using-python/

like image 133
C Fairweather Avatar answered Oct 31 '25 00:10

C Fairweather



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!