Delete files inside subfolder
조회 수: 41 (최근 30일)
이전 댓글 표시
Hello,
I have a folder:
Testfolder
Inside are:
1.mat
1.txt
1.wav
SubTestfolder
Inside SubTestfolder are:
2.mat
2.txt
2.wav
I do
Del_path = fullfile(TestFolderPath,SubTestFoldername);
delete(Del_path,'*.mat')
I was waiting that 2.mat should be deleted, but it will be 1.mat deleted, not 2.mat. Why? How can I delete files/all files in subfolder?
Thank you!
댓글 수: 0
채택된 답변
Fangjun Jiang
2020년 6월 26일
use dir('**/*.mat') to find files in subfolders in one shot and then use a for-loop to delete the files.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!