keep few images and delete the rest in a folder

2 Ansichten (letzte 30 Tage)
Elysi Cochin
Elysi Cochin am 4 Aug. 2022
Bearbeitet: Elysi Cochin am 4 Aug. 2022
Suppose I have 10 images, and i have saved all the pathname and filename in a variable all_files
I have a vector b = [ 2 4 6 ];
Now I want to keep only these images and delete all the other 7 images
How to keep those images and delete the rest?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Aug. 2022
dels = setdiff(1:length(all_files), b);
arrayfun(@(idx)delete(all_files{idx}), dels);

Weitere Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by