Skip to content

Instantly share code, notes, and snippets.

@rysk-t
Created November 2, 2015 00:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rysk-t/27fe40ed4d878802fde3 to your computer and use it in GitHub Desktop.
Save rysk-t/27fe40ed4d878802fde3 to your computer and use it in GitHub Desktop.
MATLABで、あるフォルダ以下のサブフォルダのリストを作る => 任意の拡張子のファイルパスを取得 (ここでは*.jpg)
ldirs = genpath(pwd);
ldirs = [';' ldirs];
sepidx = strfind(ldirs, ';');
for i = 1:length(sepidx)-1
gpath{i} = ldirs(sepidx(i)+1:sepidx(i+1)-1);
end
j = 1;
for i = 1:length(gpath)
fpathcur = dir([gpath{i} '\*.jpg']);
if length(fpathcur)>0
for f =1:length(fpathcur)
jpgs.full{j} = [gpath{i} '\' fpathcur(f).name];
jpgs.file{j} = fpathcur(f).name;
j = j+1;
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment