Why .DS_Store file come up when I read a folder using function in gui matlab?

30 vues (au cours des 30 derniers jours)
My folder in laptop (mac) only contain wav files. When I try to read folder using function in matlab gui, this .DS_Store file suddenly come up in the file directory (Listbox).
Anyone know why this happen and how to solve it?
Thanks
  2 commentaires
Stephen23
Stephen23 le 17 Août 2020
"My folder in laptop (mac) only contain wav files...."
and DS_Store files (which by default are not displayed by your OS):
Epri Pratiwi
Epri Pratiwi le 17 Août 2020
Thanks for the info!

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 17 Août 2020
Those files are created by the finder for any folder that you open in the finder window. They store information about the size and positions and attributes like label color, for each file in the directory.
You can delete the file and the only consequence is that the icon order or size might look different the next time you open the directory in the finder.
MATLAB has nothing to do with these files.
Notice that the file name begins with a period. There is a convention in Unix systems that any file or directory whose name begins with period will not appear by default when you use the system ls utility, and Mac extended that to those files and directories not showing up by default in the finder. You can, however, configure the finder to show them.
They show up in MATLAB because the system calls that request information about the directory return information about everything in the directory, and it is up to the code to filter the hidden ones out if appropriate for the code. There is no option in the system calls to automatically filter out the dot directories.
We can see that the code already filters out the . and .. directories that are included by the dir() call ; the code could be extended to filter dot files. It should probably be extended to only list sound files. Or possibly sound files and subdirectories so that the user can move between directories.
  1 commentaire
Epri Pratiwi
Epri Pratiwi le 17 Août 2020
I just tried to upload the sound file to google drive, then download it. When I run my gui again, suddenly the DS_store file is gone. So weird. Dunno why.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by