How to delete files ending with odd number?
Mostrar comentarios más antiguos
Hi,
I would like to delete each files having its filename ending by an odd number. Example: file0 file1 file2 file3 file4 After: file0 file2 file4
Thank you for your help :)
Respuesta aceptada
Más respuestas (1)
Morgane Flament
el 13 de Ag. de 2018
0 votos
4 comentarios
Simon Henin
el 13 de Ag. de 2018
Sure, instead of checking if mod(fileno, 2)== 1, you could look at the remainder:
if rem(fileno, 10) == 1 | rem(fileno, 10) == 2,
% then delete the file
end
Morgane Flament
el 13 de Ag. de 2018
Editada: Morgane Flament
el 13 de Ag. de 2018
Paolo
el 13 de Ag. de 2018
@Morgane,
If you wish to delete only files ending with 2,3,4 or 5, change the character set in the regex:
regexp(files(i).name, '[2345]$', 'match')
Morgane Flament
el 13 de Ag. de 2018
Categorías
Más información sobre Standard File Formats en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!