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
  Python 3.13(Windows) does not have the latest module OS phillip_from_oz 1 826 Dec-13-2024, 04:35 AM
Last Post: deanhystad
  For Loop assigns only the latest value from List Caliban86 3 1,191 Sep-22-2024, 02:47 AM
Last Post: deanhystad
  Get latest version off website and save it as variable [SOLVED] AlphaInc 5 3,094 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 2,598 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Running latest Python version on the Terminal (MAC) Damian 4 3,624 Mar-22-2021, 07:58 AM
Last Post: Damian
  Latest file with a pattern produces an error tester_V 4 4,542 Dec-10-2020, 02:14 AM
Last Post: tester_V
  Read plotly-latest.min.js from local issac_n 1 3,108 Nov-18-2020, 02:08 PM
Last Post: issac_n
  How to save latest time stamp in a file? redwood 12 9,995 Jul-11-2019, 11:03 AM
Last Post: redwood
  How to install latest version of 'pygame' sylas 1 11,285 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,773 Nov-30-2017, 06:23 AM
Last Post: kiran_j

Forum Jump:

User Panel Messages

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