how read files from different folders

조회 수: 9 (최근 30일)
pruth
pruth 2015년 11월 3일
댓글: Image Analyst 2019년 6월 7일
i have a folder with name 'year-2010' in this folder there 12 subfolders for 12 months(jan,feb,march ...dec.) and again in each month folder i have 30 or 31 subfolders for days .... and in each day folder i have my files(HDF5 format) which i want to read and do operations... i dont want put all files in one folder and however that is not possible... ... hope u understood my question ...waiting for answer!!!
  댓글 수: 2
vishal rawat
vishal rawat 2019년 6월 7일
You got the solution please shear with me I have also same problem
Image Analyst
Image Analyst 2019년 6월 7일
Solutions were shared below in the "Answers" section of this page.

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

채택된 답변

Jan
Jan 2015년 11월 3일
You find a lot of submissions for searching in folders recursively:
E.g. this submission has a lot of votes: FEX:enhanced rdir
You get a list of file names with paths. Now create a loop over these file names and use movefile or copyfile to write them to the wanted location. The functions fileparts and fullfile might be useful.

추가 답변 (2개)

Image Analyst
Image Analyst 2015년 11월 3일
See my attached demo, which uses genpath().
Of course you could always just make up your folder names with sprintf() if they have names that are known in advance, and then use the FAQ http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F, but the genpath() method is better if you don't know the folder names in advance.
  댓글 수: 2
pruth
pruth 2015년 11월 4일
편집: pruth 2015년 11월 4일
hey... thanks that really works.
but i got the list of data files in command window. i have written a code to read the files and do some operations.
i want to make an array of those files which are listed in command window so i can run my code in single loop for all those files. could u help me.
how to put all files in one folder or in one array.
i just started using matlab 3 weeks ago.
Image Analyst
Image Analyst 2015년 11월 4일
Sorry I saw this late, but it looks like you've accepted an answer so I assume you have this solved and this comment is not relevant anymore. Besides, I didn't understand the question anyway or how the FAQ doesn't answer it.

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


hajira ashiq
hajira ashiq 2018년 6월 25일
i want to read files from folder with a singe matlab file. for example, nitrogen nd chloroful is individuay calculted when i run these files. but i want to run both files at a time with single run time.when i run the main file , the nitrogn nd chlorful is automaticaly calculated

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by