FTPLIST        List current FTP site directory to a file

Top  Previous  Next

Syntax:

FTPLIST

[ file name ] [ wildcards ]

Arguments:

[ file name ]

Optional variable or string defining a file name to write the directory listing to; if no path is defined Robo-FTP writes to a file named "sitelist.txt" in the working folder.

 

[ wildcards ]

Optional variable or string defining a wildcard pattern to apply to the directory listing. The [ file name ] option must be present if this optional argument is to be recognized.  Wildcards are not permitted when connected to a SFTP, HTTP, or HTTPS site.

 

 

This script command creates a file containing a directory listing from the current folder on the current remote site. If [ file name ] is not specified, Robo-FTP creates a file in the working folder named "sitelist.txt". The directory listing written to this file is exactly as it is returned from the remote server so it is similar to what might be produced using the MLSD or LIST commands in a command line FTP client. If the remote server returns an empty listing, an empty directory listing file will be written and no error will occur. If the file already exists, it will be overwritten.

 

Important

The FTPLIST command is provided for auditing and tech support purposes only. Do not build scripts or other processes that depend on the parsing the output file created by FTPLIST. Instead you should use the FTPGETFILE or GETSITEFILE commands when designing a system that responds dynamically to the existence of remote files. The snapshot database generated by the FTPDIFF command might also be useful if you simply need to detect changes.

 

If you need a directory listing of a folder other than the current site directory, you’d need to first change directories. For example:

 

FTPCD "new_dir"

FTPLIST "listing of new_dir.txt"

 

Here’s a sample listing from an FTP server hosted on a Unix system. The actual format will vary from site to site depending on the server.

 

drwxr-x---  2 roboftp  System      0 Jan 29 20:44 .

drwxr-x---  2 roboftp  System      0 Jan 29 20:44 ..

-rwxr-x---  1 roboftp  System  62976 Jan 29 20:44 bszip.dll

-rwxr-x---  1 roboftp  System    651 Jan 29 20:44 crontab.txt

-rwxr-x---  1 roboftp  System 413184 Jan 29 20:44 cryptotw.dll

-rwxr-x---  1 roboftp  System  32768 Jan 29 20:44 feedback.exe

-rwxr-x---  1 roboftp  System     17 Jan 29 20:44 welcome.txt

 

If you want a partial listing controlled by a wildcard pattern (e.g., all .txt files), use the following form of the command and the listing received will be as shown.

 

FTPLIST "listing of new_dir.txt" "*.txt"

 

rwxr-x---  1 roboftp  System    651 Jan 29 20:44 crontab.txt

rwxr-x---  1 roboftp  System     17 Jan 29 20:44 welcome.txt

 

Note: It is not uncommon for an HTTP and HTTPS site to refuse directory listings, in these cases the FTPLIST command may fail. Some servers return content that is not actually a raw directory listing.

 

Use the LISTDIR script command to get a listing of a local folder.

 

 

Related command(s): FTPCD, FTPMAKEDIR, FTPDELDIR, FTPPWD, LISTDIR

See also: %servertype, %currentsitedir