Find number of files in multiple subfolders with specific extension

23 ビュー (過去 30 日間)
monkey_matlab
monkey_matlab 2016 年 11 月 11 日
コメント済み: Image Analyst 2016 年 11 月 11 日
Hello,
I have multiple sub folders in one main folder. These multiple sub folders contains files with the same extension .pgm. How do I go about finding the total number of files in all the subfolders with that specific extension?
I am trying the following:
x = '*.pgm';
AA = size(dir(x),1)
How do I then go through each subfolders?

回答 (1 件)

Image Analyst
Image Analyst 2016 年 11 月 11 日
dir() can now look inside subfolders if you use two asterisks . See the help.
  2 件のコメント
monkey_matlab
monkey_matlab 2016 年 11 月 11 日
I did a:
dir('**.pgm')
in the main folder, but I got the response '**.pgm' not found.
I also did a
help dir
but could not get a proper way to get the number of files in all the subfolders.
Image Analyst
Image Analyst 2016 年 11 月 11 日
You didn't use it correctly. Check the help again. See my attached demo for how to use it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by