Using Matlab, I want to move the images present in the same directory in two new directories according to their name.
In the directory there are two set of image' name: 'neg-0.pgm', 'neg-1.pgm', 'neg-2.pgm', ... and 'pos-0.pgm', 'pos-1.pgm', 'pos-2.pgm', ...
I tried different functions to change the image directory but I wasn't able to make the operation successfully.
My code is:
if not(exist('./CarDataset/TrainImages/PosImages', 'dir'))
mkdir ./CarDataset/TrainImages PosImages
end
if not(exist('./CarDataset/TrainImages/NegImages', 'dir'))
mkdir ./CarDataset/TrainImages NegImages
end
trainIm = dir('./CarDataset/TrainImages/*.pgm');
for i = 1:size(trainIm, 1)
if(strcmp(trainIm(i).name, 'neg*.pgm'))
save(fullfile('./CarDataset/TrainImages/NegImages', ['neg-' num2str(i) '.pgm']))
end
end
I don't get any error but the new directories are still empty.