这是一个forloop,旨在将多个文件夹中的多个文件移动到'RawData'目录中。我在使用movefile时遇到问题。我希望将文件移动为可变,而不是在命令中键入的字符串。
如果需要更好地理解,这是文件夹列表的一部分:
'Data-20141003T091843-1-Eyes Open on Flat Surface-Force.csv'
'Data-20141003T091843-1-Eyes Open on Flat Surface-Results.csv'
'Data-20141003T091923-2-Eyes Closed on Flat Surface-Force.csv'
'Data-20141003T091923-2-Eyes Closed on Flat Surface-Info.csv'
'Data-20141003T091923-2-Eyes Closed on Flat Surface-Results.csv'
'Data-20141003T092208-3-Limits of Stability-Force.csv'
'Data-20141003T092208-3-Limits of Stability-Info.csv'
>>foldername = foldername.name;
directoryname = 'C:\Users\murphy\Documents\MATLAB\RawData\';
folderdirectory = strcat(directoryname,foldername);
cd(folderdirectory);
folderdir = dir('*.csv');
folderList = {folderdir.name}'; %List of Files in folder
for f = 1:length(folderList) **movefile(folderList(f),'C:\Users\murphy\Documents\MATLAB\RawData')**
end
答案 0 :(得分:0)
folderList是一个cellstr。 在for循环中,您需要传递folderList {f}而不是folderList(f)。
for f = 1:length(folderList)
movefile(folderList{f},'C:\Users\murphy\Documents\MATLAB\RawData')
end