dir function help

1 次查看(过去 30 天)
James
James 2011-8-6
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 个评论
Image Analyst
Image Analyst 2011-8-6
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 2011-8-7
@James: Please post a copy of the complete error message.

请先登录,再进行评论。

回答(3 个)

Paulo Silva
Paulo Silva 2011-8-6
perhaps the bar is the other one?
dir('videos\*.jpg)
  1 个评论
Pierre
Pierre 2011-8-6
'/' as file separator should also work on Windows systems too. (At least it does on mine.)

请先登录,再进行评论。


Fangjun Jiang
Fangjun Jiang 2011-8-6
dir(['videos',filesep,'*.jpg'])
  1 个评论
Pierre
Pierre 2011-8-6
(Just for convenience issues: fullfile('videos', '*.jpg') is equivalent to your statement and comes in quite handy for deeper stacked directory structures.)

请先登录,再进行评论。


Pierre
Pierre 2011-8-6
  • 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?

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by