Borrar filtros
Borrar filtros

How can I delete files within subfolders?

8 visualizaciones (últimos 30 días)
caroline Figueroa
caroline Figueroa el 14 de Sept. de 2016
Editada: Stalin Samuel el 14 de Sept. de 2016
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!

Respuestas (1)

Stalin Samuel
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

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by