Apply functions or m to a folder(multiple files)
3 ビュー (過去 30 日間)
古いコメントを表示
I got a folder with say 100 file with the random names of haah.xls,kiij.xls etc. I have a function(say QQQ.m) I want to apply to them which would eventually convert the file to csv. I want to do two things: 1)How to apply QQQ.m to the folder 2)I want to rename the converted file according to its original name.Now the function does this, convert haah.xls to 1.csv. I want it to automatically rename to haah.csv Thanks in advance!!!
1 件のコメント
Jan
2011 年 9 月 14 日
If you post yozur code, it would be easy to explain which single line has to be changed. Without seeing your code, we could only reply a theoretical description of what muist be changed.
So please show us, what you have done already.
回答 (1 件)
Jan
2011 年 9 月 14 日
- Use DIR to get a list of files.
- Then use a FOR loop to get one file after the other.
- Read the file. It is impossible to get a more specific instruction, because you did not explain the format of the files.
- Write the converted file using the same file name, but the different file extension. This is smarter than writing "1.csv" and using MOVEFILE to rename the file afterwards.
If you include more details in your question, a more specific answer is possible.
[EDITED]: You must have the original file name to read the file. So why do you use "1.csv" and not something like:
[fPath, fName] = fileparts(OriginalFileName);
newfileName = fullfile(fPath, [fName, '.csv']);
cell2csv(newFileName, W);
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!