rmdir

Delete a directory of an FTP server.

Attention: Valid only with Altair Communication Extension.

Syntax

[R, msg1, msg2] = rmdir(ftpObj, dirname)

[R, msg1, msg2] = rmdir(ftpObj, dirname, 's')

Inputs

ftpObj
FTP object
Type: FTP object
dirname
Name of the directory to be deleted.
Type: string
's'
Additional option which specifies if the files and sub-directories under dirname should be deleted.
Type: string

Outputs

R
Returns 1 if successful; returns 0 if not successful.
msg1
Returns an error message if the command is not succcessful.
msg2
Returns the command name rmdir if the command is not succcessful.

Examples

Delete an empty directory:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
disp('Contents of ''Folder1'':')
dir(ftpObj, 'Folder1')
% 'Folder1' is empty so it can be deleted directly
rmdir(ftpObj,'Folder1');
% Check that 'Folder1' is deleted
disp('Contents of the remote root directory after deleting ''Folder1'':')
dir(ftpObj)
close(ftpObj);
Contents of 'Folder1':
ans = 
Contents of the remote root directory after deleting 'Folder1':
ans = drwxrwxrwx   1 owner    group           0 Feb 20 11:05 Folder2
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file1.txt
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file2.txt
Delete a directory recursively:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
disp('Contents of ''Folder2'':')
dir(ftpObj, 'Folder2')
% 'Folder2' is not empty so it has to be deleted recursively 
rmdir(ftpObj,'Folder2', 's');
% Check that 'Folder2' is deleted
disp('Contents of the remote root directory after deleting ''Folder2'':')
dir(ftpObj)
close(ftpObj);
Contents of 'Folder2':
ans = drwxrwxrwx   1 owner    group           0 Feb 20 11:23 Folder2_1
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file2_1.txt
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file2_2.txt

Contents of the remote root directory after deleting 'Folder2':
ans = drwxrwxrwx   1 owner    group           0 Feb 20 11:20 Folder1
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file1.txt
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file2.txt