필터 지우기
필터 지우기

How can I delete files within subfolders?

조회 수: 8 (최근 30일)
caroline Figueroa
caroline Figueroa 2016년 9월 14일
편집: Stalin Samuel 2016년 9월 14일
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!

답변 (1개)

Stalin Samuel
Stalin Samuel 2016년 9월 14일
편집: Stalin Samuel 2016년 9월 14일
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

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by