How can I delete files within subfolders?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi matlab users,
I would like to delete specific files within subfolders in my directory. I have about a 100 subject folders in one directory (subj 01001, 01002 etc). I would like to remove only the .nii files within a subfolder 'rest', which is in all the subject's folders. So far I have figured out how to do this for 1 subject at a time. I was wondering if there is a way to remove the .nii files within al the subfolders of the subjects at once? This what I am using for one subject: delete('/data/caroline/01001/rest/*.nii")
Does anyone have a script for this?
Thank you in advance!
0 comentarios
Respuestas (1)
Stalin Samuel
el 14 de Sept. de 2016
Editada: Stalin Samuel
el 14 de Sept. de 2016
get the list of all the sub folders in a variable ,For example variable 'a'
Then delete the files using below command
for it=1:n %n is the length of the folder list
delete(sprintf('/data/caroline/01001/%s/*.nii"',a{it}))
end
0 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!