dir function help

Hi
I want to be able to list all the jpg files within a folder called videos. Can anyone explain why my code does not work:
dir('videos/*.jpg)
I get the error videos/*.jpg not found. Please help

2 comentarios

Image Analyst
Image Analyst el 6 de Ag. de 2011
Well you're missing a trailing quote, but that won't give that error. Did you follow the guidelines for the second example of this section of the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Jan
Jan el 7 de Ag. de 2011
@James: Please post a copy of the complete error message.

Iniciar sesión para comentar.

Respuestas (3)

Paulo Silva
Paulo Silva el 6 de Ag. de 2011

0 votos

perhaps the bar is the other one?
dir('videos\*.jpg)

1 comentario

Pierre
Pierre el 6 de Ag. de 2011
'/' as file separator should also work on Windows systems too. (At least it does on mine.)

Iniciar sesión para comentar.

Fangjun Jiang
Fangjun Jiang el 6 de Ag. de 2011

0 votos

dir(['videos',filesep,'*.jpg'])

1 comentario

Pierre
Pierre el 6 de Ag. de 2011
(Just for convenience issues: fullfile('videos', '*.jpg') is equivalent to your statement and comes in quite handy for deeper stacked directory structures.)

Iniciar sesión para comentar.

Pierre
Pierre el 6 de Ag. de 2011

0 votos

  • Are you in the right working directory? Check with pwd and/or check whether the results of dir (without any parameters) contains a directory called "videos".
  • If there is no file matching the pattern, this error will appear. You won't simply get an empty result (although I agree this should be the case).
  • Did you eventually forget about the case sensitivity of Linux systems?

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 6 de Ag. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by