Python Forum
Python ftp server get the latest sub-directory name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python ftp server get the latest sub-directory name
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get latest version off website and save it as variable [SOLVED] AlphaInc 5 1,891 Nov-14-2021, 09:00 PM
Last Post: DeaD_EyE
  How to take the tar backup files form remote server to local server sivareddy 0 1,871 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Running latest Python version on the Terminal (MAC) Damian 4 2,591 Mar-22-2021, 07:58 AM
Last Post: Damian
  Latest file with a pattern produces an error tester_V 4 3,121 Dec-10-2020, 02:14 AM
Last Post: tester_V
  Read plotly-latest.min.js from local issac_n 1 2,131 Nov-18-2020, 02:08 PM
Last Post: issac_n
  How to save latest time stamp in a file? redwood 12 7,053 Jul-11-2019, 11:03 AM
Last Post: redwood
  How to install latest version of 'pygame' sylas 1 10,284 May-19-2018, 10:03 AM
Last Post: snippsat
  Need help in Python script to BIND with OID(Oracle Internet Directory) Server kiran_j 0 3,183 Nov-30-2017, 06:23 AM
Last Post: kiran_j
  3.6.2 is latest stable release right? And "path length" Fran_3 3 3,296 Aug-01-2017, 02:04 PM
Last Post: Fran_3
  UPDATING PYTHON TO USE LATEST VERSION OF JAVA? nicklesprout 6 7,318 Jul-27-2017, 08:58 PM
Last Post: nicklesprout

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020