lundi 7 août 2017

randomly move files from a folder to another folder?

I am trying to move my files and create a new folder to put those files there. I have many .png files in my images folder in my MATLAB directory. I want to randomly choose 80% of them and move them to another folder called training folder in my matlab directory. Heres my code which is not working. it cant find the file to move :(

data_add = fullfile(cd,'images');
all_files = dir(data_add);
all_files = all_files(3:end);
num_files = numel(all_files);
image_order = randperm(num_files);
for k = 1:(image_order)*0.8  
     file_name = all_files(k).name;
     file_add = all_files(k).folder;
     file_to_move = fullfile('path_to_images\images',file_name);
     mkdir training
    movefile file_to_move training

end




Aucun commentaire:

Enregistrer un commentaire