MATLAB: Move files to another folder.

dicomfilesimagesmovefile

I cropped a few dicom images and placed test on the cropped images (test1.dcm, test2.dcm,….).
Now I want to grab them altogether and put them in a new folder. I am trying this with no luck. Any suggestion?
for indx=3:m listing(indx).name A = dicomread(strcat( 'C:\Echo Images\Stelios\FDB.dcm\' , listing(indx).name)); imshow(A); I3 = imcrop(A, [200.5 59.75 591 480]); %A = imresize(A, [360, 280]); W = dicomwrite(I3, strcat('C:\Echo Images\Stelios\FDB.dcm\test', int2str(indx-2) , '.dcm')); file_to_move = fullfile(newdir,W) movefile(file_to_move,newdir) end

Best Answer

After all, files are created. Use
movefile('*.dcm', newdir);
to move all files together.