-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstripEmpties.m
35 lines (33 loc) · 1.03 KB
/
stripEmpties.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [dirStructNew, names] = stripEmpties(dirStruct)
% STRIPEMPTIES remove '.' and '..' files from a 'dir' output
%
% Syntax:
% [DIRSTRUCTNEW, NAMES] = STRIPEMPTIES(DIRSTRUCT)
%
% Description:
% get the file names and a cleaned up structure object for a
% directory call with 'dir', removing any empty files '.' and '..'
%
% Inputs:
% dirStruct structure output typically from a dir() command
%
% Outputs:
% dirStructNew dirStruct without '.' and '..' rows
% names names of folders/files as cell array
%
% Examples:
%
% See also
% dir, stripEmptyFolders
%
% Authors:
% S. Fregosi <[email protected]> <https://github.com/sfregosi>
% Created with MATLAB ver.: 9.9.0.1524771 (R2020b) Update 2
%
% FirstVersion: unknown
% Updated: 13 February 2023
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
names = {dirStruct.name}';
dirStructNew = dirStruct(~ismember(names, {'.','..'}));
names = names(~ismember(names, {'.','..'}));
end