Manage directories and save a new file in a specific directory
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I have a bunch of folders named A,B,C... ect. inside a single folder.
Inside each of those folders, I have folders that are dated 7-1-13,7-5-13,7-19-13... ect.
Inside each of those folders, I have anywhere from 2-99 excel files that I need to do processing on.
I don't need to know how to process my data, I just want to have matlab go into each "A,B,C" folder and look at every single sub-folder and be able to write a file inside each "A,B,C" folder.
I have a little code to process all the excel files I just don't know how to navigate through all of these folders. I know 'cd' is the way you change directories but how do I do it so I don't spend 8 hours trying to figure out how to do it! Thanks!
0 件のコメント
回答 (2 件)
G PRAKASH
2014 年 1 月 24 日
編集済み: Walter Roberson
2014 年 1 月 24 日
try this
clc
clear all
close all
M1={'slno','name'};
sheet='test1';
xlswrite('C:\Documents and Settings\Vlsi\Desktop\filename', M1, sheet,'B1:C1')
a=[1:4]';
b={'A';'B';'C';'D'};
xlswrite('C:\Documents and Settings\Vlsi\Desktop\filename', a, sheet,'B2')
xlswrite('C:\Documents and Settings\Vlsi\Desktop\filename', b, sheet,'C2')
0 件のコメント
Walter Roberson
2014 年 1 月 24 日
Just remember that the names returned by dir() do not have the name of the containing directory prefixed to them.
master = 'C:\MyData';
aaa = dir(master);
aaa(~[aaa.isdir]) = []; %get rid of non-dirs
for K = 1 : length(aaa)
thisdir = aaa(K).name;
if strcmp(thisdir, '.') || strcmp(thisdir, '..'); continue; end
thisdir = [master '/' thisdir];
bbb = dir(thisdir);
for J = 1 : length(bbb) ....
...
end
end
Notice there was no "cd" needed.
0 件のコメント
参考
カテゴリ
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!