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!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With