How to change file extension to '.xlsx' BUT keep original files?

조회 수: 3 (최근 30일)
NH
NH 2013년 3월 22일
Hello,
I am trying to change files with extension '.stp' to '.xlsx' while also keeping the original '.stp' files. I have code that replaces the '.stp' files with '.xlsx', but it does not keep the originals:
files=dir('*.stp')
for i=1:length(files)
filename=files(i).name;
[pathstr, name, ext] = fileparts(filename);
movefile(filename, fullfile(pathstr, [name '.xlsx']))
end
Also, for some reason I am unable to open the resulting '.xlsx' files. However, when I write them to '.xls' they open with no problems. This is a problem because I need the files '.xlsx' format. If anyone knows how to solve this problem as well, it would be greatly appreciated.
I am running Matlab 2013a on a Mac.

채택된 답변

Image Analyst
Image Analyst 2013년 3월 22일
Use copyfile() instead of movefile().
  댓글 수: 3
Kelly Kearney
Kelly Kearney 2013년 3월 22일
Changing the extension of a file doesn't change its format, only its name.
Image Analyst
Image Analyst 2013년 3월 22일
You'd need to read the data in with some kind of .stp file reader, into variables in MATLAB. Then write out those variables with xlswrite().

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by