Main Content


List folder contents on device



dir(device,folder) lists the files in a folder on the ROS or ROS 2 device. Wildcards are supported.

clist = dir(device,folder) stores the list of files as a structure.


collapse all

Connect to a ROS device and list the contents of a folder.

Connect to a ROS device. Specify the device address, user name, and password of your ROS device.

d = rosdevice('','user','password');

Get the folder list of a Catkin workspace on your ROS device. View the folder as a table.

flist = dir(d,'/home/user/Documents/mw_catkin_ws/');
ftable = struct2table(flist)
ftable=6×4 table
            name                            folder                    isdir    bytes
    _____________________    _____________________________________    _____    _____

    {'.'                }    {'/home/user/Documents/mw_catkin_ws'}    true       0  
    {'..'               }    {'/home/user/Documents/mw_catkin_ws'}    true       0  
    {'.catkin_workspace'}    {'/home/user/Documents/mw_catkin_ws'}    false     98  
    {'build'            }    {'/home/user/Documents/mw_catkin_ws'}    true       0  
    {'devel'            }    {'/home/user/Documents/mw_catkin_ws'}    true       0  
    {'src'              }    {'/home/user/Documents/mw_catkin_ws'}    true       0  

Input Arguments

collapse all

ROS or ROS 2 device, specified as a rosdevice or ros2device object, respectively.

Name of the folder to list the contents of, specified as a character vector.

Output Arguments

collapse all

Contents list, returned as a structure. The structure contains these fields:

  • name — File name (char)

  • folder — Absolute path (char)

  • bytes — Size of the file in bytes (double)

  • isdir — Indicator of whether name is a folder (logical)

Introduced in R2019b