FTP-list of files

Jan Schenkel janschenkel at yahoo.com
Fri Jul 5 07:13:01 EDT 2002


--- Dave Cragg <dcragg at lacscentre.co.uk> wrote:
> At 9:28 am +0200 5/7/02,
> =?utf-8?Q?mazzapaolo at liber?= wrote:
> >How can I get the list of the files  posted in a
> server using FTP?
> 
> You can get a directory listing by just using the
> directory path in 
> the url. For example:
> 
> get url "ftp://somehost/path/directory/"
> 
> But you'll have to parse the reply to extract only
> the file names.
> 

Which you can do easily by filtering the results, as
files start with a '-' and folders/directories/however
you like to call themstart with a 'd'.
So in this case.

  put URL("ftp://user:paswd@theserver.com/thepath/"\
    into theDirContent #don't forget the last '/'
  filter theDirContent with "-"

As the filenames are at the end of each lineand items
are delimited with a space, you can then retrieve
those with the following script:

  put the itemDelimiter into oldDelim
  set the itemDelimiter to " "
  put empty into theFileList
  #process each line -- FAST thanks to 'for each'
  repeat for each line theLine of theDirContent
    put item -1 of theLine & return after theFileList
  end repeat
  #get rid of the trailing return
  delete char -1 of theFileList
  set the itemDelimiter to oldDelim


Hope this helped a bit,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish
at the same time."  (De Rochefoucald)

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



More information about the use-livecode mailing list