Created
November 2, 2015 00:11
-
-
Save rysk-t/27fe40ed4d878802fde3 to your computer and use it in GitHub Desktop.
MATLABで、あるフォルダ以下のサブフォルダのリストを作る => 任意の拡張子のファイルパスを取得 (ここでは*.jpg)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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