I have a folder with n amount of files. Each file is saved as follows:
1n1 – type 3.csv
2n2 – type 3.csv
77fn.csv
3n3 – type 4.csv
4n4 – type 3.csv
5n5 – type 4.csv
6n6 – type 4.csv
7n7.csv
And so on. The files end with "type 3" or "type 4" or with a random name. I need the script to save all the files that end in "type 3" in a folder named "X" and the files that end with "type 4" to be stored in a folder named "Y". And the files that don't end neither with "type 3" nor "type 4" to be stores in a folder name Z. Any information is helpful. Thank you!
ALLfiles='\All_Files\'; X='\X\; Y='\Y\'; Z='\Z\'folder= ALLfiles;data3=fullfile(folder,'*.csv');directory=dir(data3);for w=1:length(directory) name{w}=getfield(directory(w),'name'); name{w}= strfind(name{w},'type 3');%insert if statement, if "type 3" exists in name of the file, movefile to X
elseif "type 4" exist in name of the file movefile to Yelse move file to Zend
Best Answer