David Bolen db3l at fitlinxx.com
Tue Feb 27 02:48:54 CET 2001

"Andrea Ciuffoli" <ACIUFFO1 at irf.com> writes:

> Hello,
> I am using the "Ftplib" library to connect my PC to an FTP server, list =
> all the files of a specific directory and transfer only the ones created =
> in the last hour.
> My problem is that the command
> ftp.retrlines('LIST',listing.append)
> appends in listing some information about the file but I noticed that if =
> the file is created in 2001 doesn't store the year among the information =
> while if it is created in 2000 or before doesn't stores the year but not =
> the time.

That's really up to the FTP server that you connect to, but is fairly
typical of Unix output format, so I'm guessing you're connecting to
some variant of Unix server.  If the file is within the past year, it
shows full date/time - if more than a year old, it shows date and
year.  In other words, this is the same sort of listing you'd get if
you were locally on that server and asked for a directory from the

The LIST command in FTP brings back an ASCII (or EBCDIC), human
readable directory listing, but its format is not standardized, so
servers are free to pretty much do whatever they want.  It's intended
to be easy for humans to view but not required to be easy for
computers to parse.

There's probably not much you can do about this; although some servers
may process Unix-like options (which may modify the output format) as
part of the arguments to the LIST command, it's pot-luck and not
something to depend on.

Parsing the format isn't too bad though since the presence of a colon
can tell you which format each line is in.  Of course if you
absolutely need the timestamp for a file more than a year old, you may
have a problem :-) But since you mention pulling those from the last
hour, this shouldn't be much of an issue.

-- David
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \

More information about the Python-list mailing list