Use dir for files not in any folder

Hello every one,
I wanted to know if I can use dir commant for files that are not in any folder! ( In fact I want to know if I have to put the .mat files inside any folder and then use dir command)
Currently using dir command gives zero results for me.
data_list=dir('VectrinoData.228.22.Vectrino Profiler.00000/*.mat'); %This gives 0*1 struct

10 comentarios

Stephen23
Stephen23 el 17 de Ag. de 2022
"..files that are not in any folder"
What is a file that is "not in any folder" ?
Walter Roberson
Walter Roberson el 17 de Ag. de 2022
dir() can operate on the current directory; for example dir('*.mat')
You can also do things like dir('VectrinoData.228.22.Vectrino Profiler.*.mat')
mehra
mehra el 17 de Ag. de 2022
a data file like the one attached.
Okay, what about it?
dinfo = dir('VectrinoData.228.22.Vectrino Profiler.00000.mat')
and then you would be able to examine dinfo.name, dinfo.isfolder, and so on.
mehra
mehra el 17 de Ag. de 2022
The problem is that when I use dir('VectrinoData.228.22.Vectrino Profiler.00000.mat') it gives:
1*0 struct
empty result
Then as far as MATLAB can tell, that file does not exist in the current directory.
What shows up if you use
dinfo = dir('V*.mat')
{dinfo.name}.'
mehra
mehra el 17 de Ag. de 2022
ın fact the exact file exists and matlab does not give any error, just the output is zero!
But I used your command and it worked
Thanks
Walter Roberson
Walter Roberson el 17 de Ag. de 2022
What exactly showed up for the output of the above two commands?
Jan
Jan el 17 de Ag. de 2022
Editada: Jan el 17 de Ag. de 2022
@mehra : Check this again. I'm convinced that you have over seen something:
file = 'VectrinoData.228.22.Vectrino Profiler.00000.mat'
isfile(file)
folder = cd
list = dir(fullfile(folder, '*.mat'))
{list.name}
What output do you get?
This actually worked. But did not know how to accept the answer
dinfo = dir('V*.mat')
And by reducing the numbers of 0 (zeros) in the nam eof the file it also worked. so I guess there was something related with the name of the file.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 17 de Ag. de 2022

Comentada:

el 17 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by