필터 지우기
필터 지우기

what will be the query for calling a folder(by path) to do the following loop or anything?

조회 수: 1 (최근 30일)
what will be the query for calling a folder(by path) to do the following loop or anything?

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 8일
projectdir = 'path/to/the/folder';
dinfo = dir(projectdir);
dinfo( ismember({dinfo.name}, {'.', '..'}) ) = []; %get rid of . and ..
dinfo( [dinfo.isdir] ) = []; %get rid of subfolders if you want to
entries = fullfile(projectdir, {dinfo.name} );
numfiles = length(entries);
results = cell(numfiles, 1);
for K = 1 : numfiles
thisentry = entries{K};
% process information for thisentry
...
results{K} = ....
end
  댓글 수: 6
Thara C.S
Thara C.S 2018년 12월 9일
but i have to save each file with different name to a folder? the file has to be changing in each 'k' (each entry files).
so how i do that?
file_name='C:\Users\Thara c.s\Pictures\new for\new2OMI-Aura_L3-OMSO2e_2007m0101_v003-2018m0531t145810.he5.tif';
in the above example, 'new2OMI-Aura_L3-OMSO2e_2007m0101_v003-2018m0531t145810.he5'' is to change and also keep the .tif extension.
Walter Roberson
Walter Roberson 2018년 12월 9일
in what II posted above you would change newentry however is appropriate . the code i posted shows how to extract the base name the new20 part but excluding the extension and then shows saving to a different folder and with a different extension . You could easily instead do something like the same folder but with 'processed_' as a prefix or whatever is appropriate . fileparts to break the input name into parts then do appropriate string manipulation then put the result together into the output file name .

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by