comment savoir si un dossier est vide

3 visualizzazioni (ultimi 30 giorni)
Dann Laneuville
Dann Laneuville il 24 Set 2024
Commentato: Mathieu NOE il 2 Ott 2024
comment savoir si un dossier (folder) est vide en une instruction

Risposte (1)

Mathieu NOE
Mathieu NOE il 24 Set 2024
hello
The dir structure will return only the two directories entries '.' and '..'. So, check length(d)==2, if that is the case the folder is empty
emptyfolder = (length(dir(folderName))==2) % logical output (1 if folder empty)

Community Treasure Hunt

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

Start Hunting!