dir

Class: FTP

View contents of folder on FTP server

Syntax

dir(ftpobj)
dir(ftpobj,folder)
details = dir(ftpobj,folder)

Description

dir(ftpobj) lists the files in current folder on the FTP server associated with ftpobj.

dir(ftpobj,folder) lists the files in the specified folder.

details = dir(ftpobj,folder) returns the results in a structure array that contains the name, modification date, and size of each file.

Input Arguments

ftpobj

FTP object created by ftp.

folder

Character vector enclosed in single quotation marks that specifies the target folder. To specify the folder above the current one, use '..'.

Output Arguments

details

m-by-1 structure array, where m is the number of files in the folder. Each element of the structure array contains the following fields:

Field NameDescriptionData Type
name

File name

char

date

Modification date timestamp

char

bytes

Number of bytes allocated to the file

double

isdir

If a folder, isdir = 1, otherwise isdir = 0

logical

datenum

Modification date as serial date number

char

Examples

Connect to the National Geophysical Data Center (NGDC) FTP server and view the contents:

ngdc = ftp('ftp.ngdc.noaa.gov');
dir(ngdc)

This code returns:

 
DMSP                         Solid_Earth                  international            wdc                          
INDEX.txt                    ftp.html                     ionosonde                                        
README.txt                   geomag                       mgg                                                 
STP                          hazards                      pub                                                       
Snow_Ice                     index.html                   tmp                                                       

Continuing the previous example, save the folder contents to the structure n, close the connection, and view details about the pub subfolder:

n = dir(ngdc);
close(ngdc);

n(14)

This code returns:

ans = 

       name: 'pub'
      bytes: 9
      isdir: 1
       date: '12-Dec-2014 21:22:00'
    datenum: 7.3595e+05

FTP service courtesy of the NGDC. See NGDC Privacy Policy, Disclaimer, and Copyright for NGDC terms of service.

See Also

| | |

Introduced before R2006a

Was this topic helpful?