MATLAB: Matlab source code for file selection

I am doing a project on Video Compression. My problem is that i have a folder named "Snaps" that contains all the frames of the video. I want to select a number of sequential files having a certain interval and save those files into another folder named "Newsnaps". Can anyone please help me with the source code on this matter??

Best Answer

Hi,
If I understood correctly you want to read the files from the folder Snaps, subsample them and then save them on a new folder called NewSpnas.
video_dir = 'snaps/'
extension = 'jpg'
out_dir = 'Newsnaps/'
step = 2 % this parameter decide which frames to save
resnames=dir(fullfile(video_dirs,['*.' extension]));
for i=1:step:length(resnames)
img=imread(fullfile(video_dirs,resnames(i).name));
imwrite(img, [out_dir resnames(i).name]);
end