This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

cd

Change or view current folder on FTP server

Syntax

cd(ftpobj,folder)
cd(ftpobj)
newFolder = cd(___)

Description

example

cd(ftpobj,folder) changes the current folder on the FTP server associated with ftpobj.

cd(ftpobj) displays the path to the current folder on the server.

newFolder = cd(___) also returns the path as a character vector. You can use the input arguments from either of the previous syntaxes. If you use the first syntax, then newFolder is the path after you change the folder.

Examples

collapse all

Connect to an FTP server and navigate to a folder on that server.

First, connect to the National Centers for Environmental Information (NCEI) FTP server.

ftpobj = ftp('ftp.ngdc.noaa.gov')
ftpobj = 

  FTP Object
     host: ftp.ngdc.noaa.gov
     user: anonymous
      dir: /
     mode: binary

Display the contents of the top-level folder. It contains another folder named pub.

dir(ftpobj)
 
DMSP                         Solid_Earth                  google12c4c939d7b90761.html  mgg                          
INDEX.txt                    coastwatch                   hazards                      pub                          
README.txt                   dmsp4alan                    index.html                   tmp                          
STP                          ftp.html                     international                wdc                          
Snow_Ice                     geomag                       ionosonde                                                 
 

Change folders to the pub folder. Then display its contents.

cd(ftpobj,'pub')
ans = 
'/pub'
dir(ftpobj)
 
WebCD     coast     glac_lib  krm       outgoing  results   rgon                                                                  
 

FTP service courtesy of the National Centers for Environmental Information (NCEI). See the NCEI Privacy Policy, Disclaimer, and Copyright for NCEI terms of service.

Input Arguments

collapse all

Connection to an FTP server, specified as an FTP object.

Name of the target folder on the FTP server, specified as a character vector or string scalar. To specify the folder above the current one, use '..'.

See Also

|

Introduced before R2006a