Python ftp server get the latest sub-directory name - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python ftp server get the latest sub-directory name (/thread-12097.html) |
Python ftp server get the latest sub-directory name - muzamalrana - Aug-08-2018 I am trying to write a script to get the latest file from the latest sub- directory of FTP server in python. My problem is i am unable to figure out the latest sub-directory. There are 2 options available, sub-directories have ctime available. Also in directory name date is mentioned that on which date directory was created.But i do not know how to get the name of the latest directory. I have figured out the following way(hoping for the server side to be sorted by latest c time but it is super slow. import ftplib import os import time ftp = ftplib.FTP('test.rebex.net','demo', 'password') ftp.cwd(str((ftp.nlst())[0])) #if directory is sorted in descending order by date. But is there any way where i will find the exact directory by Ctime or by date in directory name ? Thanks a lot guys Python ftp server get the latest sub-directory name - muzamalrana - Aug-08-2018 Hello Friends, I am very new to Python.I am trying to write a script to get the latest file from the latest sub- directory of FTP server in python. My problem is i am unable to figure out the latest sub-directory. There are 2 options available, sub-directories have ctime available. Also in directory name date is mentioned that on which date directory was created.But i do not know how to get the name of the latest directory. I have figured out the following way(hoping for the server side to be sorted by latest c time but it is super slow.But is there any way where i will find the exact directory by Ctime or by date in directory name ? Thanks a lot guys import ftplib import os import time ftp = ftplib.FTP('test.rebex.net','demo', 'password') ftp.cwd(str((ftp.nlst())[0])) #if directory is sorted in descending order by date |