Validates the output of dir, ignores hidden files and provides wished output.
Updated 15 Apr 2016

View License

% p = dirvalid([],varargin) or p=dirvalid: without specified folder dirvalid will return cd
% p = dirvalid(folder) returns only valid folders and files and ignores
% hidden files within folder.
% p = dirvalid('',varargin), varargin is optional. See varargin options for specific outputs.
% [p,f] = dirvalid() seperates folders (p) from files (f).
% Ben van Oeveren, VU-Amsterdam, 15-Apr-2016
%% varargin (output) options:
% 'struct': default, will give the same output as dir
% 'name': 'example'
% 'path': 'example.ext'
% 'fullpath': 'anotherfolder/myfolder/example.ext'
% 'f': only files
% 'p': only folders

Cite As

Ben Oeveren (2024). dirvalid(folder,varargin) (https://www.mathworks.com/matlabcentral/fileexchange/56578-dirvalid-folder-varargin), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on File Operations in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes