MATLAB: Help with if-else statement

elseifif elsepathstatement

Hi. So I have these files…
'20130401_SPLBRENT3_concat.mat'
'20130402_SPLBRENT3_concat.mat'
'20130403_SPLBRENT3_concat.mat'
'20130404_SPLBRENT3_concat.mat'
'20130405_SPLBRENT3_concat.mat'
'20130410_SPLBRENT3_concat.mat'
'20130411_SPLBRENT3_concat.mat'
'20130422_SPLBRENT3_concat.mat'
'20130424_SPLBRENT3_concat.mat'
'20130425_SPLBRENT3_concat.mat'
'20130426_SPLBRENT3_concat.mat'
'20130427_SPLBRENT3_concat.mat'
'20130429_SPLBRENT3_concat.mat'
'20130430_SPLBRENT3_concat.mat'
'20130501_SPLBRENT3_concat.mat'
'20130502_SPLBRENT3_concat.mat'
'20130503_SPLBRENT3_concat.mat'
'20130506_SPLBRENT3_concat.mat'
'20130517_SPLBRENT3_concat.mat'
'20130518_SPLBRENT3_concat.mat'
'20130519_SPLBRENT3_concat.mat'
'20130520_SPLBRENT3_concat.mat'
'20130521_SPLBRENT3_concat.mat'
'20130522_SPLBRENT3_concat.mat'
'20130523_SPLBRENT3_concat.mat'
'20130524_SPLBRENT3_concat.mat'
'20130527_SPLBRENT3_concat.mat'
'20130528_SPLBRENT3_concat.mat'
'20130529_SPLBRENT3_concat.mat'
'20130530_SPLBRENT3_concat.mat'
'20130531_SPLBRENT3_concat.mat'
These are data files from April (201304) and May (201305). I am trying to do an "if else" statement that will send the files with the first numbers 201304 to the path 'T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1304' and the files with the numbers 201305 to the path 'T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1305'. Notice that files aren't there from every day, so they're not a sequence. I'm pretty sure this is done with "if else" but I am not sure.
Can anyone help?
Thanks

Best Answer

Let the OS perform the pattern matching:
Dest1 = 'T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1304';
Dest2 = 'T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1305';
Source = 'D:\ParentFolderOfYourFiles';
movefile(fullfile(Source, '201304*.mat'), Folder1);
movefile(fullfile(Source, '201305*.mat'), Folder2);
Related Question