Reputation: 41
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!
Upvotes: 4
Views: 8401
Reputation: 3727
When I want to change the file modification time, I use an FTP client on the console. Log on to a remote FTP ftp ftp.dic.com
change the access time, modification time, it's time to create a directory on 2005-01-01 12:30:00 somefile.txt
Complete example:
site UTIME somefile.txt 20150331122000 20150331122000 20150331122000 UTC
Of course you can use this command in any ftp client.
Upvotes: 0
Reputation: 696
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/
Upvotes: 8