You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
wrapper for ls, which lists the files in one or more folders
patterns can use combinatorial logic (and, or, not, etc)
patterns can use regexp or ls syntax
output can be a structure (ala ls), or a cell array of filenames.
examples:
list all files with extensions txt and m
[textfiles,mfiles] = lsr('*.txt','*.m');
m-files starting with A or B, names only (two examples)
foo = lsr('A* or B* and *.m','-name')
foo = lsr('^[A|B].*\.m$','-name')
txt files larger than 1MB and all mat files
foo = lsr('size>1mb and txt or mat')
Cite As
Christopher Pedersen (2026). lsr (https://uk.mathworks.com/matlabcentral/fileexchange/46047-lsr), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.4.0.0 (57.2 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.4.0.0 | changed recursion of subfolders to use fileattrib instead of genpath
|
||
| 1.3.0.0 | New warnings when receiving patterns that might be ambiguous.
|
||
| 1.2.0.0 | fixed bug where using -root and -path option together caused filenames to start with / or \ |
||
| 1.1.0.0 | changed -root to be an optional output
|
||
| 1.0.0.0 |
