필터 지우기
필터 지우기

Using multiple files from folder

조회 수: 2 (최근 30일)
Alexandros
Alexandros 2011년 11월 28일
Hello
I have a script that takes some xls files and rearrange them to put them into a new xls files. While also i have a folder where all the initial xls files exist. The names of the xls files are BAG?.xls and TEMP?.xls where ? can be from 1 to millions of file.
e.g. in the folder BAG1.xls TEMP1.xls BAG2.xls TEMP2.xls BAG3.xls TEMP3.xls exist.
Now my script has been program so that it ask me every time the BAG file and TEMP file name and does it's actions to rearrange them.
How is it possible to tell the script to scan the folder to see how many files we have then to take BAG1 and TEMP1 do the actions, then automatically take BAG2 and TEMP2 do the actions and to continue like this?
Thank you in advance Alex
  댓글 수: 1
Alexandros
Alexandros 2011년 11월 28일
I YES FORGOT
THERE IS ALSO OTHER FILES IN THERE WHICH I DONT NEED

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

채택된 답변

Jan
Jan 2011년 11월 28일
This is explained in the FAQ:
Reading the FAQ is strongly recommended, because all beinners can profit from the frequent errors of others and they do not have to re-invent the errors again.
See the dir command.
list = dir(fullfile(YourDataPath, 'BAG*.xls'));
for iList = 1:length(list)
disp(list(iList).name);
% Do your processing here
end
  댓글 수: 1
Alexandros
Alexandros 2011년 11월 28일
This is exactly what i needed. Now i just put list(ilist).name inside a variable and continue with my excel actions

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by